zblogphp获取阿里妈妈优惠价方式

核心代码:

获取查询结果函数:

function pub_alimama($key) {
  $url="https://pub.alimama.com/items/search.json?q=".$key."&toPage=1&dpyhq=1&perPageSize=40&shopTag=yxjh=-1%2Cdpyhq";
  $ajax = Network::Create();
  $ajax->open('GET', $url);
  $ajax->enableGzip();
  $ajax->setTimeOuts(60, 60, 0, 0);
  $ajax->send();
  return json_decode($ajax->responseText);}

将查询结果转换成数组,并专递给前端页面:

$alimama=pub_alimama("数据库修复");
$article=$alimama->data->pageList;
$zbp->template->SetTags('article',$article);

前端查询相关信息:

{foreach $articles as $article}
掌柜: {$article->nick}
产品名: {$article->title}
店铺名: {$article->shopTitle}
产品首图: {$article->pictUrl}
产品ID: {$article->auctionId}
产品连接: {$article->auctionUrl}
月销:{$article->biz30day}
佣金:{$article->tkCommFee}
销售分数:{$article->totalNum}
产品价格:{$article->zkPrice}
优惠券金额:{$article->couponAmount}
{/if}


阿里PHPZBlog