简体   繁体   English

Rackspace php-opencloud API调用-无法使importCredentials()正常工作

[英]Rackspace php-opencloud API calls - can't get importCredentials() to work

I am using the php-opencloud / Rackspace SDK. 我正在使用php-opencloud / Rackspace SDK。

I only have one user connecting to the API, which is the entire site that is running. 我只有一个用户连接到API,该用户正在运行的整个站点。

By default it will make an authentication request before every API call, which is of course crazy. 默认情况下,它将在每个API调用之前发出一个身份验证请求,这很疯狂。

I want to simply cache the token (I'm thinking apc_add() / apc_fetch()) and then pass it in next time to prevent that extra API call. 我只想缓存令牌(我在考虑apc_add()/ apc_fetch()),然后在下一次传递它以防止额外的API调用。 There will be one token for the whole site so this makes sense to me. 整个站点只有一个令牌,因此这对我来说很有意义。

This is what I have but it's not recognising the data and it just keeps making the extra API call in line 2 anyway. 这就是我所拥有的,但是它无法识别数据,因此无论如何总是在第2行中进行额外的API调用。

What am I doing wrong? 我究竟做错了什么? How would I simply pass in a token to stop it making authentication API calls? 我如何简单地传递令牌以阻止其进行身份验证API调用?

// uses https://github.com/rackspace/php-opencloud

$client->importCredentials(array('token'=>'the-token', 'expiration'=>'2014-03-01T01:02:09.384Z', 'tenant'=>'xxxxxxxx'));    

$queue = $client->queuesService('cloudQueues', 'LON', 'internalURL')->setClientId();

When you implement caching , you'll want to use exportCredentials . 实现缓存时 ,您将需要使用exportCredentials If not, you'll manually have to make sure you have all the fields correctly set (namely, token , expiration , tenant , and catalog ). 如果不是,则必须手动确保正确设置了所有字段(即tokenexpirationtenantcatalog )。

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

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