/**
  * @return Taoapi_Config
  */
 public static function Init()
 {
     if (!self::$_init) {
         self::$_init = new Taoapi_Config();
     }
     return self::$_init;
 }
 public function __construct()
 {
     if (self::$Taoapi_Util == NULL) {
         self::$Taoapi_Util = new Taoapi_Util();
     }
     $Config = Taoapi_Config::Init();
     $this->ApiConfig = $Config->getConfig();
     $this->Cache = new Taoapi_Cache();
     $this->Cache->setClearCache($this->ApiConfig->ClearCache);
 }
 function index_action()
 {
     if (empty($_REQUEST['ajax'])) {
         $query = $GLOBALS['db']->query('select id,sitename,siteurl,css,logo,hot from ' . tname('site') . ' where ctype=1 and recommend=1 order by sort desc,hot desc limit 0,16');
         while ($rows = $GLOBALS['db']->fetch_array($query)) {
             $site_top_one[] = $rows;
         }
         if (!checkfile('site_top', 180)) {
             foreach ($GLOBALS['sitecate'] as $k => $v) {
                 $query = $GLOBALS['db']->query('select id,sitename,cityid,siteurl,css,pinyin,sitetype,ctype,logo,hot from ' . tname('site') . ' where sitetype=' . $k . ' and recommend=1 order by sort desc,hot desc limit 0,30');
                 while ($rows = $GLOBALS['db']->fetch_array($query)) {
                     $site_top[$rows['sitetype']][] = $rows;
                 }
             }
             write('site_top', $site_top);
         } else {
             $site_top = read('site_top');
         }
         /*热购商品列表开始*/
         $queryPro = $GLOBALS['db']->query('select pid,title,pic_url,link_url,webUrl,webName,price from ' . tname('products') . ' where status=1 order by uptime desc limit 0,15');
         while ($rowsPro = $GLOBALS['db']->fetch_array($queryPro)) {
             $productslist[] = $rowsPro;
         }
         $productsindex = $productslist;
         /*热购商品列表结束*/
         /*淘宝商城女装数据调用开始*/
         $Taoapi_Config = Taoapi_Config::Init();
         $Taoapi = new Taoapi();
         //搜索商品信息(taobao.items.get)
         $ItemsParam['method'] = 'taobao.items.get';
         $ItemsParam['fields'] = 'num_iid,title,detail_url,pic_url,nick,cid,price,type,delist_time,post_fee,score,volume';
         $ItemsParam['q'] = '品牌';
         $ItemsParam['cid'] = '16';
         $ItemsParam['page_no'] = '1';
         $ItemsParam['page_size'] = '15';
         $ItemsParam['order_by'] = 'volume:desc';
         $ItemsParam['ww_status'] = 'true';
         $ItemsParam['is_3D'] = 'false';
         $ItemsParam['is_mall'] = 'true';
         $ItemsParam['genuine_security'] = 'true';
         $ItemsParam['stuff_status'] = 'new';
         $Taoapi->setUserParam($ItemsParam);
         //传入参数
         $Taoapi->setVersion(2);
         //1表示 1.0版,2 表示2.0版
         $ItemsData = $Taoapi->Send('get', 'xml')->getArrayData();
         //print_r($ItemsData);
         //die();
         /*淘宝商城女装数据调用结束*/
         $cityWeather = $this->_cityWeather();
         //加载天气城市
         $weatherRow = $this->_siteweather();
         //加载天气
         //$citygroup=$this->_citygroup();
         $indexgroup = $this->_indexquanguogroup();
         //$grouplist=$this->_quanguogroup();
         $txtsitelist = $this->_indexCateTosite();
         include template('index');
     } elseif ($_REQUEST['ajax'] == 1) {
         //$citygroup=$this->_citygroup();
         $txtsitelist = $this->_indexCateTosite();
         //$grouplist=$this->_quanguogroup();
         include template('ajax_textsite');
     } else {
         $citypage = intval($_REQUEST['citypage']);
         $grouplist = $this->_citygroup(1, $citypage);
         include template('ajax_citygroup');
     }
 }
Exemple #4
0
<?php

include "common.inc.php";
InitGP(array("action", "keyword", "refuname", "referer", "aid", "cityid"));
//初始化变量全局返回
//当前版本:Taoapi TOP PHP SDK 2.2
header("Content-type:text/html; charset=UTF-8");
include_once 'library/Taoapi.php';
$Taoapi_Config = Taoapi_Config::Init();
$Taoapi_Config->setCharset('UTF-8');
$Taoapi = new Taoapi();
if (!empty($keyword)) {
    //搜索商品信息(taobao.items.search)
    $Taoapi->method = 'taobao.items.search';
    $Taoapi->fields = 'iid,detail_url,pic_url,num_iid,title,nick,type,cid,seller_cids,props,input_pids,input_str,desc,pic_path,num,valid_thru,list_time,delist_time,stuff_status,location,price,post_fee,express_fee,ems_fee,has_discount,freight_payer,has_invoice,has_warranty,has_showcase,modified,increment,auto_repost,approve_status,postage_id,product_id,auction_point,property_alias,itemimg,propimg,sku,outer_id,is_virtural,is_taobao,is_ex,video,itemList,categoryList';
    $Taoapi->q = $keyword;
    $Taoapi->cid = '16';
    $Taoapi->order_by = 'seller_credit';
    $Taoapi->is_mall = 'true';
    //需要更多的字段可以登陆 taoapi.com 进行配置生成
    $TaobaokeData = $Taoapi->Send('get', 'xml')->getArrayData();
}
echo '<pre>';
//检测API是否遇到错误
if ($Taoapi->getErrorInfo()) {
    echo lang('api_error');
    print_r($Taoapi->getErrorInfo());
}
//打印获取到的API数据结果
print_r($TaobaokeData[item_search][items][item]);
print_r($TaobaokeData[total_results]);
 public function __construct()
 {
     $Taoapi_Config = Taoapi_Config::Init();
     $this->setCacheTime($Taoapi_Config->getConfig()->Cache);
     $this->setCachePath($Taoapi_Config->getConfig()->CachePath);
 }