首页 菜谱大全 菜谱大全示例代码 根据ID查询详情[PHP]

根据ID查询详情示例代码[PHP]

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

根据ID查询详情

<?php

require_once 'curl.func.php';

$appkey = 'your_appkey_here';//你的appkey
$id = 5;
$url = "https://api.jisuapi.com/recipe/detail?appkey=$appkey&id=$id";
$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'];

echo $result['id'].' '.$result['classid'].' '.$result['name'].' '.$result['peoplenum'].'
'; echo $result['preparetime'].' '.$result['cookingtime'].' '.$result['content'].' '.$result['pic'].' '.$result['tag'].'
'; foreach($result['material'] as $v) { echo $v['mname'].' '.$v['type'].' '.$v['amount'].'
'; } foreach($result['process'] as $v) { echo $v['pcontent'].' '.$v['pic'].'
'; }