如何使用php代码管理AWS Pinpoint活动AWS-Sdk
问题描述:
我们正在使用AWS Pinpoint webservice为Android和iOS推送推送通知。我们已经在AWS pinpoint控制台中创建并启动了广告系列。 但我们希望从其他网络服务器管理细分受众群,广告系列等,以便我们不必反复登录AWS控制台(客户的要求)。如何使用php代码管理AWS Pinpoint活动AWS-Sdk
对于这样的需求,我使用AWS php sdk来实现目标。我写的只是简单的代码
require_once 'aws-sdk/aws-autoloader.php';
use Aws\AwsClient;
$objClient = new Aws\AwsClient([
'version' => 'XXX',
'region' => 'XXX',
'credentials' => [
'key' => 'XXX',
'secret' => 'XXX'
]
]);
但它给以下错误:
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'The service "" is not provided by the AWS SDK for PHP.' in /opt/lampp/htdocs/researchworks/vipin/pinpoint-demo/aws-sdk/Aws/functions.php:347 Stack trace: #0 /opt/lampp/htdocs/researchworks/vipin/pinpoint-demo/aws-sdk/Aws/AwsClient.php(129): Aws\manifest('') #1 /opt/lampp/htdocs/researchworks/vipin/pinpoint-demo/index.php(13): Aws\AwsClient->__construct(Array) #2 {main} thrown in /opt/lampp/htdocs/researchworks/vipin/pinpoint-demo/aws-sdk/Aws/functions.php on line 347
我已经使用了https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-Aws.Pinpoint.PinpointClient.html精确documantation。 请提供问题的解决方案。
答
不知道如何实例化一个原始AWS客户端,但我猜如果你提供"Pinpoint"
作为service
参数它可能工作。
从documentation provided针尖客户端可以被实例化,并呼吁
require_once 'aws/aws-autoloader.php';
use Aws\Pinpoint\PinpointClient;
$client = PinpointClient::factory(array(
'profile'=>'CREDENTIAL_PROFILE', //Or you can provide the raw credentials as you did in your sample
'region'=>'us-east-1',
'version'=>'2016-12-01'
));
$result = $client->getApps();
print $result;
感谢您的宝贵建议。是的你是对的,我纠正了我的错误,并且包括'使用Aws \ Pinpoint';'所以,我能够实例使用$ objPinpoint =新AWS \精确定位\ PinpointClient对象([ \t \t \t \t '版本'=> 'XXX', \t \t \t \t '区域'=> 'XXX', \t \t \t \t '凭证'=> [ \t \t \t \t \t '键'=> 'XXX', \t \t \t \t \t '秘密'=> 'XXX' \t \t \t \t] \t \t \t]); –
但现在我面临新的问题。实例化对象后,我试图调用文档中提供的函数,但它提供了以下错误:致命错误:Uncaught异常'Aws \ Pinpoint \ Exception \ PinpointException'带消息'错误正在执行“GetApps”on“https://pinpoint.us- east-1.amazonaws.com/v1/apps“; AWS HTTP错误:cURL错误35:与pinpoint.us-east-1.amazonaws.com:443有关的未知SSL协议错误(请参阅http://curl.haxx.se/libcurl/c/libcurl-errors.html) '异常'GuzzleHttp \ Exception \ ConnectException'带有消息 –
'cURL错误35:与pinpoint.us-east-1.amazonaws.com:443有关的未知SSL协议错误(请参阅http://curl.haxx.se/libcurl /c/libcurl-errors.html)'in /opt/lampp/htdocs/researchworks/vipin/aws-sdk-new/GuzzleHttp/Handler/CurlFactory.php:186堆栈跟踪:#0/opt/lampp/htdocs/researchworks /vipin/aws-sdk-new/GuzzleHttp/Handler/CurlFactory.php(150):GuzzleHttp \ Handler \ CurlFactory :: createRejection(Object(GuzzleHttp \ Handler \ EasyHandle),Array)#1/opt/lampp/htdocs/researchworks /vipin/aws-sdk-new/GuzzleHttp/Handler/CurlFactory.php(103): –