Fan-BAPI 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.fan-b.com/';
// $obapi->api_urls = array('http://api.fan-b.com/','http://api-1.fan-b.com/');//备用API服务器
$obapi->api_urls_on = true;//当网络错误时,是否启用备用API服务器
$obapi->api_key = '';
$obapi->api_secret = '';
$obapi->api_version ='';
$obapi->secache_path ='runtime/';
$obapi->secache_time ='86400';

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

用时:0.07363秒

Error:string(23) "Error JSON data format:"

获取分类代码如下:
 

$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:

用时:0.06429秒

Error:string(23) "Error JSON data format:"

获取产品代码如下:
 
//示例:获取产品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.fan-b.com All Rights Reserved. QQ:271449542