PHP code example of verystar / aliyun-acm

1. Go to this page and download the library: Download verystar/aliyun-acm 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/ */

    

verystar / aliyun-acm example snippets


use Aliyun\ACM\Client;

$client = new Client([
    "accessKey"=>"***********",
    "secretKey"=>"***********",
    "endPoint"=>"acm.aliyun.com",
    "nameSpace"=>"***********",
    "timeOut"=>30, //long pull timeout default 30s
]);


//get config
$ret = $client->getConfig("test","DEFAULT_GROUP");
print_r($ret);

//subscribe 
$ret = $client->subscribe("test","DEFAULT_GROUP");
print_r($ret);

//pulish
$ret = $client->publish("test","DEFAULT_GROUP","config content");
print_r($ret);


//remove config
$ret = $client->delete("test","DEFAULT_GROUP");
print_r($ret);

//get all config by tenant
$ret = $client->getAllConfigs(1,1);
print_r($ret);

use Aliyun\ACM\RequestException;

try{
    $ret = $client->getConfig("test","DEFAULT_GROUP");
    print_r($ret);    
}catch (RequestException $e){
    print_r($e);   
}