PHP code example of jdcloud-api / jdcloud-sdk-php

1. Go to this page and download the library: Download jdcloud-api/jdcloud-sdk-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/ */

    

jdcloud-api / jdcloud-sdk-php example snippets


$fix_endpoint = EndpointProvider::patterns([
    '*/*' => ['endpoint' => 'vm.cn-north-1.jdcloud-api.com'] //指定非默认访问地址 step 1
]);

$vm = new VmClient([
    'credentials'  => new Credentials('ak', 'sk'),
    'version' => 'latest',
     'debug' => [
         'logfn'        => function ($msg) { echo $msg . "\n"; }, //输出调试详细日志
         ],
     'validate' => false, //关闭客户端参数验证
     'endpoint_provider' => $fix_endpoint, //指定非默认访问地址 step 2
     'scheme' => 'https',
     'http'    => [
        'verify' => 'C:/ca-bundle.crt', //指定本地证书文件
        'connect_timeout' => 20,   //指定连接超时  
	'proxy' => 'http://192.168.16.1:10', //指定代理
         'timeout' => 5   //指定请求超时 
    ]
]);