PHP code example of iotyun / iot-huawei-php

1. Go to this page and download the library: Download iotyun/iot-huawei-php 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/ */

    

iotyun / iot-huawei-php example snippets



declare (strict_types = 1);

namespace app\index\controller;

use iotyun\huaweiiot\Huaweiiot;
use iotyun\huaweiiot\Auth;
class Index
{
    public function index()
    {
		$Authorization = array('platformIp' => '180.101.147.89', 'platformPort' => '8743', 'appId' => 'nPJmWXRg28FyLUAyd9jlixOmq0Ya', 'secret' => 'WsSHJrBKq8mDfsr_zAuQwAIFOMQa', );

		echo Huaweiiot::getVersion();
		echo '<br>';
		$auth = Auth::login($Authorization);
		echo $auth;
		echo '<br>';
		$Authorization['refreshToken'] = $auth->refreshToken;
		$refreshToken = Auth::refreshToken($Authorization);
		echo $refreshToken;
		echo '<br>';
    }
}
bash
$ composer