1、下载SDK
2、引入
include_once EWEI_SHOPV2_PATH. 'vendor/AlibabaCloud/index.php';
3、调用
$ali = new AlibabaCloudClass(1,2);
AlibabaCloud::accessKeyClient($this->accessKeyId, $this->accessSecret)->regionId('cn-shanghai')->asDefaultClient();
try {
$result = AlibabaCloud::rpc()->product('Iot')
->version('2018-01-20')->action('Pub')->method('POST')->host('iot.cn-shanghai.aliyuncs.com')->options([
'query' => [
'RegionId' => "cn-shanghai",
'TopicFullName' => "/XXXX/user/get",
'MessageContent' => "XXXXXX=",
'ProductKey' => "XXXXXX",
],
])->request();
echo "<pre>";
print_r($result->toArray());
} catch (ClientException $e) {
echo $e->getErrorMessage() . PHP_EOL;
} catch (ServerException $e) {
echo $e->getErrorMessage() . PHP_EOL;
}