PHP code example of gaoyang / aliyun-bundle

1. Go to this page and download the library: Download gaoyang/aliyun-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gaoyang / aliyun-bundle example snippets


use Aliyun\bundle\Push;

$accessKeyId = ''; 
$accessKeySecret = ''; 
$region = 'cn-shanghai';

$iot = new Iot($accessKeyId, $accessKeySecret, $region);

//以下方法参数变量自己定义;这里忽略不定义了

//创建产品
$this->createProduct($productName, $productDesc);

//修改产品
$this->updateProduct($productKey, $productName, $productDesc);

//注册设备
$this->registerDevice($productKey, $deviceName);

//根据devicename查询设备
$this->queryDeviceByName($productKey, $deviceName);

//分页查询deivce
$this->queryDevice($productKey, $pageSize, $currentPage);

//批量申请设备
$this->applyDeviceWithNames($productKey, $deviceNames);

//查询申请单执行状态
$this->queryApplyStatus($applyId);

//分页查询申请的设备
$this->queryPageByApplyId($applyId, $currentPage, $pageSize);

//批量查询设备状态
$this->batchGetDeviceStatus($productKey, $deviceNames)

//更新设备影子
$this->updateDeviceShadow($productKey, $deviceName, $shadowMessage);

//获取设备影子
$this->getDeviceShadow($productKey, $deviceName);

//查询设备属性  -- 目前只有华东2支持
$this->queryDeviceProp($productKey, $deviceName);

//保存设备属性 -- 目前只有华东2支持
$this->saveDeviceProp($productKey, $deviceName, $props);

//删除设备属性  -- 目前只有华东2支持
$this->deleteDeviceProp($productKey, $deviceName, $propKey);

//发送消息
$this->pub($productKey, $deviceName, $messageContent);

//发送广播消息
$this->pubBroadcast($productKey, $messageContent);

//rrpc请求  需要配合设备端一同使用才会成功
$this->rrpc($productKey, $deviceName, $requestBase64Byte);