PHP code example of yundun / yundunsdk
1. Go to this page and download the library: Download yundun/yundunsdk 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/ */
yundun / yundunsdk example snippets
$request = array(
'url' => 'api/version',
'body' => '',
'headers' => [
'format' => 'json',
],
'timeout' => 10,
'query' => [
'params1' => 1,
'params2' => 2
],
);
try{
$res = $sdk->get($request);
}catch (\Exception $e){
var_dump($e->getCode());
var_dump($e->getMessage());
}
exit($res);
$request = array(
'url' => 'api/version',
'body' => json_encode([
'body1' => 1,
'body2' => 2,
]),
'headers' => [
'format' => 'json',
],
'timeout' => 10,
'query' => [
'params1' => 1,
'params2' => 2
],
);
try{
$res = $sdk->post($request);
}catch (\Exception $e){
var_dump($e->getCode());
var_dump($e->getMessage());
}
exit($res);
$request = array(
'url' => 'api/version',
'body' => '',
'headers' => [
'format' => 'json',
],
'timeout' => 10,
'query' => [
'params1' => 1,
'params2' => 2
],
'options' => [
'async' => true,
'callback' => function($response){
$body = $response->getBody->getContents();
echo $body;
exit;
},
'exception' => function($exception){}
]
);
try{
$sdk->getAsync($request);
}catch (\Exception $e){
var_dump($e->getCode());
var_dump($e->getMessage());
}
$request = array(
'url' => 'api/version',
'body' => json_encode([
'body1' => 1,
'body2' => 2,
]),
'headers' => [
'format' => 'json',
],
'timeout' => 10,
'query' => [
'params1' => 1,
'params2' => 2
],
'options' => [
'async' => true,
'callback' => function($response){
$body = $response->getBody->getContents();
echo $body;
exit;
},
'exception' => function($exception){}
]
);
try{
$sdk->postAsync($request);
}catch (\Exception $e){
var_dump($e->getCode());
var_dump($e->getMessage());
}