基于php的食谱接口调用代码实例.doc
文本预览下载声明
基于php的食谱接口调用代码实例
代码描述:基于php的食谱接口调用代码实例
接口平台:聚合数据
!--?php
// +----------------------------------------------------------------------
// | JuhePHP [ NO ZUO NO DIE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2010-2015 All rights reserved.
// +----------------------------------------------------------------------
// | Author: Juhedata info@--
// +----------------------------------------------------------------------
?
//----------------------------------
// 菜谱大全调用示例代码 - 聚合数据
// 在线接口文档:/docs/46
//----------------------------------
?
header(Content-type:text/html;charset=utf-8);
?
?
//配置您申请的appkey
$appkey = *********************;
?
?
?
?
//************1.菜谱大全************
$url = /cook/query.php;
$params = array(
??????menu = ,//需要查询的菜谱名
??????key = $appkey,//应用APPKEY(应用详细页查询)
??????dtype = ,//返回数据的格式,xml或json,默认json
??????pn = ,//数据返回起始下标
??????rn = ,//数据返回条数,最大30
??????albums = ,//albums字段类型,1字符串,默认数组
);
$paramstring = http_build_query($params);
$content = juhecurl($url,$paramstring);
$result = json_decode($content,true);
if($result){
????if($result[error_code]==0){
????????print_r($result);
????}else{
????????echo $result[error_code].:.$result[reason];
????}
}else{
????echo 请求失败;
}
//**************************************************
?
?
?
?
//************2.分类标签列表************
$url = /cook/category;
$params = array(
??????parentid = ,//分类ID,默认全部
??????key = $appkey,//应用APPKEY(应用详细页查询)
??????dtype = ,//返回数据的格式,xml或json,默认json
);
$paramstring = http_build_query($params);
$content = juhecurl($url,$paramstring);
$result = json_decode($content,true);
if($result){
????if($result[error_code]==0){
????????print_r($result);
????}else{
????????echo $result[error_code].:.$result[reason];
????}
}else{
????echo 请求失败;
}
//**************************************************
?
?
?
?
//************3.按标签检索菜谱************
$url = /cook/index;
$params = array(
??????cid = ,//标签ID
??????key = $appkey,//应用APPKEY(应用详细页查询)
??????dtype = ,//返回数据的格式
显示全部