linux yundun进程,GitHub

阅读: 评论:0

linux yundun进程,GitHub

linux yundun进程,GitHub

YUNDUN API PHP SDK legend

接口遵循RESTful,默认请求体json,接口默认返回json

app_id, app_secret 联系技术客服,先注册一个云盾的账号,用于申请绑定api身份

签名

每次请求都签名,保证传输过程数据不被篡改

客户端:sha256签名算法,将参数base64编码+app_secret用sha256签名,每次请求带上签名

服务端:拿到参数用相同的算法签名,对比签名是否正确

环境要求:php >=5.5

依赖composer

##使用步骤

composer require yundun/yundunsdk

实例化

//sdk

require 'xx/vendor/autoload.php';

$app_id = 'xx';

$app_secret = 'xx';

$client_ip = 'xx';

$client_userAgent = '';

$base_api_url = '/';

;base_api_url = '127.0.0.1/V4/'

$host = 'apiv4.yundun';

$handler = 'guzzle'; //curl/guzzle默认guzzle,guzzle支持异步调用,curl驱动目前未实现异步

$sdk = new YundunSDK (

[

'app_id'=>$app_id,

'app_secret'=>$app_secret,

'base_api_url' = '127.0.0.1/V4/',

'host' => &#',

'client_ip'=>$client_ip,

'client_userAgent'=>$client_userAgent,

'handler'=> $handler,

'syncExceptionOutputCode' => 0,

'syncExceptionOutputMessage' =>'同步请求异常信息提示',

'asyncExceptionOutputCode' => 0,

'asyncExceptionOutputMessage' => '异步请求异常信息提示'

'log' => true, //是否记录sdk相关日志

'logfileWin' => 'E:/sdkV4.log', //windows日志路径

'logfileLinux' => '/tmp/sdkV4.log' //linux日志路径

]

);

调用

format json返回json,xml返回xml

body 支持传递json和数组

urlParams会拼接在url后面

支持get/post/patch/put/delete方法

sync request

get

$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);

post/put/patch/delete

$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);

async request

get

$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());

}

post/put/patch/delete

$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());

}

本文发布于:2024-02-01 03:49:24,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170673056433640.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:进程   linux   yundun   GitHub
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23