首页 谜语 谜语示例代码 谜语查询[PHP]

谜语查询示例代码[PHP]

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

谜语查询

<?php

require_once 'curl.func.php';

$appkey = 'your_appkey_here';//你的appkey
$keyword = '公鸡';//utf8
$pagesize = 1;
$pagenum = 1;
$classid = 1;//分类
$url = "https://api.jisuapi.com/miyu/search?appkey=$appkey&classid=$classid&keyword=$keyword&pagesize=$pagesize&pagenum=$pagenum";
$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['total'].' '.$result['pagesize'].' '.$result['pagenum'].' '.$result['classid'].'
'; foreach($result['list'] as $val) { echo $val['content'].' '.$val['answer'].'
'; }