简体   繁体   English

PHP OpenCloud \ Rackspace问题

[英]PHP OpenCloud\Rackspace Problems

I am having problems trying to get the Rackspace Opencloud API to work as expected (particularly the cloud files). 我在尝试使Rackspace Opencloud API按预期工作时遇到问题(尤其是云文件)。

I have been following these guides: 我一直在关注这些指南:

https://github.com/rackspace/php-opencloud/blob/master/docs/userguide/ObjectStore/Access.md http://docs.rackspace.com/sdks/api/php/namespace-OpenCloud.ObjectStore.html https://github.com/rackspace/php-opencloud/blob/master/docs/userguide/ObjectStore/Access.md http://docs.rackspace.com/sdks/api/php/namespace-OpenCloud.ObjectStore.html

The Authentication seems to work fine because a token and the service catalog is returned. 身份验证似乎工作正常,因为返回了令牌和服务目录。

header("Content-Type: text/plain");
require '/vendor/autoload.php';

use OpenCloud\Rackspace;

$client = new Rackspace('https://lon.identity.api.rackspacecloud.com/v2.0/', array(
    'username' => 'MY_USERNAME',
    'apiKey'   => 'MY_APIKEY'
));

$client->authenticate();

echo 'Authenticated with token: '.$client->getToken()."\n\n";

print_r($client->getCatalog());

My problems start when i try to use a service from the API: 当我尝试使用API​​中的服务时,我的问题开始了:

$service = $client->objectStoreService('cloudFiles');

This line kills the code. 这行杀死了代码。 I have copied the Rackspace documentation line for line but still no luck, I am unable to get any of the services to work. 我已经复制了Rackspace文档行,但仍然没有运气,我无法使任何服务工作。

Can anyone see where I'm going wrong or provide any tips for the best way to troubleshoot this issue? 任何人都可以看到我出错的地方或提供解决此问题的最佳方法的任何提示吗?

Specify the region explicitly 明确指定区域

You need to explicitly choose the region you want to use. 您需要明确选择要使用的区域。 From your identity line, it looks like you'll need to set it to LON. 从您的身份行,您似乎需要将其设置为LON。

$service = $client->objectStoreService('cloudFiles', 'LON'); # Or IAD, HKG, SYD, etc.

Side note: I just submitted a pull request on php-opencloud to make this more clear in the documentation. 旁注:我刚刚在php-opencloud上提交了一个pull请求,以便在文档中更加清晰。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM