Onebound API SDK调用示例(TAOBAO)[调用所有平台API示例][下载]


//定义缓存目录和引入文件
define('DIR_RUNTIME','runtime/');
define('DIR_ERROR','runtime/');
define('SECACHE_SIZE','0');
define('DS',DIRECTORY_SEPARATOR);

include ("ObApiClient.php");

$obapi = new otao\ObApiClient();
$obapi->api_url = 'https://api-gw.onebound.cn/';
// $obapi->api_urls = array('http://api.onebound.cn/','http://api-1.onebound.cn/');//备用API服务器
$obapi->api_urls_on = true;//当网络错误时,是否启用备用API服务器
$obapi->api_key = 'demo_api_key';
$obapi->api_secret = '';
$obapi->api_version ='';
$obapi->secache_path ='runtime/';
$obapi->secache_time ='86400';

    
示例:获取分类ID=16的商品列表 item_search:

用时:0.24848秒

获取分类代码如下:
 

$time_start = getmicrotime();

//示例:获取分类ID=16的商品列表
$api_data = $obapi->exec(array(
    'api_type' => 'taobao', 
    'api_name' => 'item_search', 
    'api_params' => array(
        'q' => '', 
        'page' => 1, 
        'cat' => 16,
        'sort' => '', 
        'page_size' => '', 
        'ppath' => '', 
        'imgid' => ''
        )));

print_r($items);
  

示例:获取产品ID=39881745164的商品详细 item_get:

用时:7.06254秒

获取产品代码如下:
 
//示例:获取产品ID=39881745164的商品详细
$api_data = $obapi->exec(
                array(
                'api_type' =>'taobao',
                'api_name' =>'item_get',
                'api_params'=>array('num_iid'=>621615764909)
                )
            );
$item = $api_data['item'];

 print_r($item);
 

Powered by:万邦 www.onebound.cn All Rights Reserved. QQ:583964941