使用php将csv上载到windows azure存储

使用php将csv上载到windows azure存储,php,azure,azure-storage,Php,Azure,Azure Storage,尝试使用PHP SDK将csv从远程URL上载到azure存储。我似乎一直在犯这个错误。我在没有使用curl的SDK的情况下尝试过它,但仍然得到相同的错误 `PUT resulted in a `403 Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.` response:  &l

尝试使用PHP SDK将csv从远程URL上载到azure存储。我似乎一直在犯这个错误。我在没有使用curl的SDK的情况下尝试过它,但仍然得到相同的错误

`PUT resulted in a `403 Server failed to authenticate the request. 
Make sure the value of Authorization header is formed correctly including the signature.` response: 
<?xml version="1.0" encoding="utf-8"?><Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate (truncated...) 
in C:\wamp64\www\azurescript\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php on line 113
以下是我正在使用的PHP代码:

<?php

require_once 'vendor/autoload.php';

use MicrosoftAzure\Storage\Common\ServicesBuilder;
use MicrosoftAzure\Storage\Common\ServiceException;
use MicrosoftAzure\Blob\Models\SetBlobPropertiesOptions;


$key = base64_encode("abc");

$connectionString = "DefaultEndpointsProtocol=https;AccountName=username;AccountKey={$key}";

$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);

// Grab the csv from the remote url
$csv = fopen("http://www.xxxxx.com/wp-cron.phpexport_hash=yyyyyy&export_id=1&action=get_data", "r");
$blobName = "test";

try    {
    // Upload the blob
    $blobRestProxy->createBlockBlob("container", $blobName, $csv);
}
catch(ServiceException $e){

    // Errors
    $code = $e->getCode();
    $errorMessage = $e->getMessage();
}

该错误与403身份验证失败有关。请确保:

  • 您的帐户名和帐户密钥有效且未过期。您可以通过尝试登录Azure Storage Explorer或检查Azure门户来确认这一点
  • 从Azure存储接收密钥后,您不需要再次进行base64_编码($key)。从Azure存储接收的密钥已进行base64_编码

  • 该错误与403身份验证失败有关。请确保:

  • 您的帐户名和帐户密钥有效且未过期。您可以通过尝试登录Azure Storage Explorer或检查Azure门户来确认这一点
  • 从Azure存储接收密钥后,您不需要再次进行base64_编码($key)。从Azure存储接收的密钥已进行base64_编码

  • 身份验证问题与未正确设置密钥有关。不知道你为什么决定对它进行编码,但是。。。您需要完全按照呈现给您的方式使用存储访问密钥


    事实上,整个连接字符串已经为您构建好了;无需自行构建。

    身份验证问题与未正确设置密钥有关。不知道你为什么决定对它进行编码,但是。。。您需要完全按照呈现给您的方式使用存储访问密钥

    事实上,整个连接字符串已经为您构建好了;不需要自己建造