我想送SNS内留言到Android通过网络API。 下载并从http://aws.amazon.com/developers/getting-started/php/
I am trying to send SNS messeges to android through web api. Downloaded and installed the SDK from http://aws.amazon.com/developers/getting-started/php/
在运行sample.php得到以下错误:
Got following error while running sample.php:
Fatal error: Uncaught exception 'Aws\Common\Exception\InstanceProfileCredentialsException' with message 'Error retrieving credentials from the instance profile metadata server. When you are not running inside of Amazon EC2, you must provide your AWS access key ID and secret access key in the "key" and "secret" options when creating a client or provide an instantiated Aws\Common\Credentials\CredentialsInterface object. ([curl] 28: Connection timed out after 5016 milliseconds [url] http://169.254.169.254/latest/meta-data/iam/security-credentials/)' in C:\xampp\htdocs\aws-php\vendor\aws\aws-sdk-php\src\Aws\Common\InstanceMetadata\InstanceMetadataClient.php:85 Stack trace: #0 C:\xampp\htdocs\aws-php\vendor\aws\aws-sdk-php\src\Aws\Common\Credentials\RefreshableInstanceProfileCredentials.php(52): Aws\Common\InstanceMetadata\InstanceMetadataClient->getInstanceProfileCredentials() #1 C:\xampp\htdocs\aws-php\vendor\aws\aws-sdk-php\src\Aws\Common\Credentials\AbstractRefreshableCredentials.php(54): Aws\Common\Credentials\Refreshable in C:\xampp\htdocs\aws-php\vendor\aws\aws-sdk-php\src\Aws\Common\InstanceMetadata\InstanceMetadataClient.php on line 85
有关此主题的一个小指南将帮助我很多
A little guidance on this topic will help me a lot
在我的情况,我用的是
return DynamoDbClient::factory(array(
'version' => 'latest',
'region' => AWS_REGION,
'key' => AWS_KEY,
'secret' => AWS_SECRET
));
这曾经是确定与 AWS / AWS-SDK-PHP
2.8.5版本,但是当作曲家自动安装3.2.0版本,我得到上述错误。这个问题很简单,我已经改变了我发出的呼吁的方式
which used to be ok with aws/aws-sdk-php
version 2.8.5 , but when composer automatically installed version 3.2.0, I got the error above. The problem is simply that I should've changed the way I made the call to
return DynamoDbClient::factory(array(
'version' => 'latest',
'region' => AWS_REGION,
'credentials' => array(
'key' => AWS_KEY,
'secret' => AWS_SECRET,
)
));
作为记录here.在不改变通话时,的的Apache 的PHP是回落到寻找〜/ .aws /凭证
文件中使用HOME环境变量,这是空。您可以通过将测试其值< PHP的echo(GETENV(HOME));在
例如和访问的链接
/var/www/test.php 的http://yourserver/test.php
,看到输出
as documented here. Without changing the call, the apache php was falling back to looking for the ~/.aws/credentials
file using the HOME environment variable, which was empty. You can test its value by placing <?php echo(getenv("HOME"));
in /var/www/test.php
for example and accessing the link http://yourserver/test.php
and seeing the output
这是一个相关的帖子