yuzewang/aliyun-open-api-iot
Composer 安装命令:
composer require yuzewang/aliyun-open-api-iot
包简介
The IOT SDK for Aliyun OpenAPI
README 文档
README
The IOT SDK for Aliyun OpenAPI
Install
Via Composer
$composer require yuzewang/aliyun-open-api-iot
Usage
use Aliyun\Core\Regions\Endpoint; use Aliyun\Core\Regions\EndpointConfig; use Aliyun\Core\Regions\EndpointProvider; use Aliyun\Core\Profile\DefaultProfile; use Aliyun\IOT\Request\RegistDeviceRequest; use Aliyun\Core\DefaultAcsClient; /** * 访问信息 */ $config = [ 'AccessKeyId'=>'<your access_key_id>', 'AccessKeySecret'=>'<your access_key_secret>', 'ProductKey'=>'<your product_key>', ]; /** * 配置网关 */ $endpoint = new Endpoint('cn-shanghai', EndpointConfig::getRegionIds(), EndpointConfig::getProductDomains()); EndpointProvider::setEndpoints([ $endpoint ]); /** * 授权资料 */ $profile = DefaultProfile::getProfile('cn-shanghai', $config['AccessKeyId'], $config['AccessKeySecret']); /** * 发消息到指定的Topic */ $client = new DefaultAcsClient($profile); $request = new Iot\PubRequest(); $request->setAppKey($config['ProductKey']); $request->setTopicFullName($appKey . "/deviceId/" . $deviceId); print_r($request->getTopicFullName()); print_r("\r\n"); $request->setMessageContent(base64_encode("open")); $response = $client->getAcsResponse($request); print_r($response); print_r("\r\n"); sleep(10); $request->setMessageContent(base64_encode("close")); $response = $client->getAcsResponse($request); print_r($response); print_r("\r\n"); [官方文档](https://help.aliyun.com/document_detail/30568.html?spm=5176.doc30594.6.134.zdfioe) ## Change log Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. ## Testing ``` bash $ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email yuze89@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 22
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-07-12