首页 元曲三百首 元曲三百首示例代码 元曲查询[PHP]

元曲查询示例代码[PHP]

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

元曲查询

<?php

require_once 'curl.func.php';

$appkey = 'your_appkey_here';//你的appkey
$keyword = '百姓苦';//utf8
$pagesize = 1;
$pagenum = 1;
$url = "https://api.jisuapi.com/yuanqu/search?appkey=$appkey&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'].'
'; foreach($result['list'] as $val) { echo $val['total'].' '.$val['pagenum'].' '.$val['pagesize'].' '.$val['title'].' '.$val['content'].' '.$val['explanation'].' '.$val['appreciation'].' '.$val['author'].'
'; }