首页 菜谱大全 菜谱大全示例代码 按分类检索[PHP]

按分类检索示例代码[PHP]

作者: 阅读数:2336 上传时间:2016-03-10

按分类检索

<?php

require_once 'curl.func.php';

$appkey = 'your_appkey_here';//你的appkey
$num = 10;
$classid = 2;//分类id(二级id)
$start = 0;
$url = "https://api.jisuapi.com/recipe/byclass?appkey=$appkey&classid=$classid&start=$start&num=$num";
$result = curlOpen($url, ['ssl'=>true]);
$jsonarr = json_decode($result, true);
//exit(var_dump($jsonarr));

if($jsonarr['status'] != 0)
{
    echo $jsonarr['msg'];
    exit();
}
$result = $jsonarr['result'];
foreach($result['list'] as $val)
{
    echo $val['id'].' '.$val['classid'].' '.$val['name'].' '.$val['peoplenum'].'
'; echo $val['preparetime'].' '.$val['cookingtime'].' '.$val['content'].' '.$val['pic'].' '.$val['tag'].'
'; foreach($val['material'] as $v) { echo $v['mname'].' '.$v['type'].' '.$v['amount'].'
'; } foreach($val['process'] as $v) { echo $v['pcontent'].' '.$v['pic'].'
'; } }