Onebound API SDK调用示例
//定义缓存目录和引入文件
define("DIR_RUNTIME","runtime/");
define("DIR_ERROR","runtime/");
define("SECACHE_SIZE","15M");
include "ObApiClient.php";
//初始化
$ob = new ObApiClient();
$ob->api_url = "http://api.onebound.cn/";
$ob->api_key = "demo_api_key";
$ob->api_secret = "";
$ob->api_version ="";
$ob->secache_path ="/tmp/";
$ob->secache_time ="86400";
$ob->cache = true;
$ob->lang = "cn";示例:获取jd API数据调用代码如下:
$result['jd'] = $ob->exec(
array(
'api_type' =>'jd',
'api_name' =>'item_get',
'api_params'=>array('num_iid'=>29186819959)
)
);Array
(
[error] => (jd.item_get)接口无权限,联系QQ:583964941。
[reason] => (jd.item_get)接口无权限,联系QQ:583964941。 接口文档:https://open.onebound.cn/help/api/jd.item_get.html
[error_code] => 4005
[success] => 0
[cache] => 0
[api_info] => today: max:500003
[execution_time] => 0.037
[server_time] => Beijing/2021-03-10 04:40:34
[client_ip] => 121.40.225.218
[call_args] => Array
(
)
[api_type] => jd
[server_memory] => 3.03MB
[request_id] => 1.6047dd4274979
[l_down_time] => 0.042
[l_cache] => 0
[l_execution_time] => 0.04201
)
用时:6.40454秒示例:获取taobao API数据调用代码如下:
$result['taobao'] = $ob->exec(
array(
'api_type' =>'taobao',
'api_name' =>'item_get',
'api_params'=>array('num_iid'=>557216270522)
)
);Array
(
[item] => Array
(
)
[error] => item-not-found
[error_code] => 2000
[reason] => item-not-found 接口文档:https://open.onebound.cn/help/api/taobao.item_get.html
[translate_status] =>
[translate_time] => 0
[language] => Array
(
[default_lang] => cn
[current_lang] => ru
)
[cache] => 0
[api_info] => today: max:50000
[execution_time] => 0.766
[server_time] => Beijing/2021-03-10 04:40:35
[client_ip] => 121.40.225.218
[call_args] => Array
(
[num_iid] => 557216270522
)
[api_type] => taobao
[translate_language] => ru
[translate_engine] => google_cn
[server_memory] => 5.14MB
[request_id] => 1.6047dd4283e1c
[l_down_time] => 0.77009
[l_cache] => 0
[l_execution_time] => 0.7701
)
用时:6.40456秒示例:获取1688 API数据调用代码如下:
$result['1688'] = $ob->exec(
array(
'api_type' =>'1688',
'api_name' =>'item_get',
'api_params'=>array('num_iid'=>564876975705)
)
);Array
(
[item] => Array
(
)
[error] => error
[translate_status] =>
[translate_time] => 0
[language] => Array
(
[default_lang] => cn
[current_lang] => ru
)
[reason] => error 接口文档:https://open.onebound.cn/help/api/1688.item_get.html
[error_code] => 5000
[cache] => 0
[api_info] => today: max:50000
[execution_time] => 5.462
[server_time] => Beijing/2021-03-10 04:40:40
[client_ip] => 121.40.225.218
[call_args] => Array
(
[num_iid] => 564876975705
)
[api_type] => 1688
[translate_language] => ru
[translate_engine] => google_cn
[server_memory] => 3.45MB
[request_id] => 1.6047dd43474be
[l_down_time] => 5.46638
[l_cache] => 0
[l_execution_time] => 5.46639
)
用时:6.40459秒示例:获取amazon API数据调用代码如下:
$result['amazon'] = $ob->exec(
array(
'api_type' =>'amazon',
'api_name' =>'item_get',
'api_params'=>array('num_iid'=>'B00GW94B1W-cn')//B016LO4UTA
)
);Array
(
[error] => key[demo_api_key]已过期,联系QQ:583964941。
[reason] => key[demo_api_key]已过期,联系QQ:583964941。 接口文档:https://open.onebound.cn/help/api/amazon.item_get.html
[error_code] => 4013
[success] => 0
[cache] => 0
[api_info] => today: max:5000
[execution_time] => 0.032
[server_time] => Beijing/2021-03-10 04:40:40
[client_ip] => 121.40.225.218
[call_args] => Array
(
)
[api_type] => amazon
[server_memory] => 2.7MB
[request_id] => 1.6047dd48b76f8
[l_down_time] => 0.03544
[l_cache] => 0
[l_execution_time] => 0.03545
)
用时:6.40460秒示例:获取mls API数据调用代码如下:
$result['mls'] = $ob->exec(
array(
'api_type' =>'mls',
'api_name' =>'item_get',
'api_params'=>array('num_iid'=>'1gmuw4o')
)
);Array
(
[error] => key[demo_api_key]已过期,联系QQ:583964941。
[reason] => key[demo_api_key]已过期,联系QQ:583964941。 接口文档:https://open.onebound.cn/help/api/mls.item_get.html
[error_code] => 4013
[success] => 0
[cache] => 0
[api_info] => today: max:5000
[execution_time] => 0.04
[server_time] => Beijing/2021-03-10 04:40:40
[client_ip] => 121.40.225.218
[call_args] => Array
(
)
[api_type] => mls
[server_memory] => 2.6MB
[request_id] => 1.6047dd48c257f
[l_down_time] => 0.04679
[l_cache] => 0
[l_execution_time] => 0.04679
)
用时:6.40461秒示例:获取translate API数据调用代码如下:
$result['translate'] = $ob->exec(
array(
'api_type' =>'translate',
'api_name' =>'t_json',
'api_params'=>array('text'=>'["Hello world","I\'m come!"]','sl'=>'en','tl'=>'zh-CN')
)
);Array
(
[error] => key[demo_api_key]已过期,联系QQ:583964941。
[reason] => key[demo_api_key]已过期,联系QQ:583964941。 接口文档:https://open.onebound.cn/help/api/translate.t_json.html
[error_code] => 4013
[success] => 0
[cache] => 0
[api_info] => today: max:5000
[execution_time] => 0.035
[server_time] => Beijing/2021-03-10 04:40:40
[client_ip] => 121.40.225.218
[call_args] => Array
(
)
[api_type] => translate
[translate_language] =>
[translate_engine] => TRANSLATOR_ENGINE
[server_memory] => 1.86MB
[request_id] => 1.6047dd48ccce3
[l_down_time] => 0.04328
[l_cache] => 0
[l_execution_time] => 0.04329
)
用时:6.40462秒