开发者社区> 问答> 正文

oss的PHPSDK根本无法使用

我装的镜像服务器(centos+nginx+php),下载oss SDK 2.0版本
按照这个 http://aliyun_portal_storage.oss.aliyuncs.com/oss_api/oss_phphtml/quickstart.html

<?phprequire_once '/path/to/sdk/aliyun.php';use \Aliyun\OSS\OSSClient;$client = OSSClient::factory(array('AccessKeyId' => '','AccessKeySecret' => '',));

$client->putObject(array(
      'Bucket'=>'youxuepai',
      'Key'=> 'effded',
      'Content'=>'This is my content'
      ));
(注:代码中 accesskeyid和accesskeysecret保证正确)
就无法运行,报莫名其妙的错误:

Fatal error:  Uncaught exception'Aliyun\OSS\Exceptions\OSSException' with message 'The bucket you areattempting to access must be addressed using the specified endpoint.Please send all future requests to this endpoint.' in/alidata/www/default/aliyun/src/Aliyun/OSS/Utilities/OSSExceptionFactory.php:16Stacktrace:#0/alidata/www/default/aliyun/src/Aliyun/OSS/ResponseHandlers/OSSErrorResponseHandler.php(29):Aliyun\OSS\Utilities\OSSExceptionFactory->createFromError(Object(Aliyun\OSS\Models\OSSError))#1/alidata/www/default/aliyun/src/Aliyun/Common/Communication/OpenServiceClient.php(40):Aliyun\OSS\ResponseHandlers\OSSErrorResponseHandler->handle(Object(Aliyun\Common\Communication\HttpResponse))#2/alidata/www/default/aliyun/src/Aliyun/Common/Communication/RetryableServiceClient.php(32):Aliyun\Common\Communication\OpenServiceClient->sendRequest(Object(Aliyun\Common\Communication\HttpRequest),Object(Aliyun\Common\Communication\ExecutionContext))#3 /alidata/www/default/aliyun/src/Aliyun/Common/Communication/Retryablein /alidata/www/default/aliyun/src/Aliyun/OSS/Utilities/OSSExceptionFactory.php on line 16

展开
收起
老杨-cd 2014-05-17 17:40:31 12498 0
3 条回答
写回答
取消 提交回答
  • Reoss的PHPSDK根本无法使用
    兄弟,这个报错是创建bucket的节点与默认SDK的节点不一致导致的。alisdk\src\Aliyun\OSS\Resources\default.options.php定义了默认节点是杭州节点 。
    你可以用endpoint参数来定义选择bucket的节点域名,就不报错了。
    推荐你看下这个 http://bbs.aliyun.com/read/149100.html?spm=5176.7114037.1996646101.11.OcjlGh
    2014-06-07 14:14:32
    赞同 展开评论 打赏
  • 新版的我在哪里好像看到有php版本限制,但是你试试旧版的,比如V1的,我试了下,至少传文件可以,其他还没试。
    http://help.aliyun.com/view/13438816.html
    2014-05-18 15:16:37
    赞同 展开评论 打赏
  • Reoss的PHPSDK根本无法使用,技术支持也不给力
    还没开始就把我给拒之门外

    -------------------------

    Reoss的PHPSDK根本无法使用
    是的,旧版的可以用
    2014-05-17 17:41:31
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
OSS运维进阶实战手册 立即下载
《OSS运维基础实战手册》 立即下载
OSS运维基础实战手册 立即下载