时间:2021-07-01 10:21:17 帮助过:10人阅读
有答案马上结贴
$url="http://api.94qing.com/?type=alexa&msg=111";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
$content = curl_exec($ch);
需要传递 cookie
给个专用函数
function QQLite_get($msg, $type='jm') { $url = 'http://api.94qing.com'; $cookiejar = realpath('cookie.txt'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiejar); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $r = curl_exec($ch); curl_setopt($ch, CURLOPT_URL, "$url?type=$type&msg=$msg"); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar); $r = curl_exec($ch); curl_close($ch); return $r;}echo QQLite_get('老虎'); //中文要 utf-8 编码的echo QQLite_get('大象');您搜索的解梦关键词:老虎
这个我原来用过,地址好像是:http://api.qqlite.org
哇,版主大人啊,我马上试试看
http://api.94qing.com/ 这个接口有什么限制吗? 也可以说是在哪种情况下会让你用不了?
版主的方法可以实现,不过在BAE中不能用
需要传递 cookie
给个专用函数
function QQLite_get($msg, $type='jm') { $url = 'http://api.94qing.com'; $cookiejar = realpath('cookie.txt'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiejar); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $r = curl_exec($ch); curl_setopt($ch, CURLOPT_URL, "$url?type=$type&msg=$msg"); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar); $r = curl_exec($ch); curl_close($ch); return $r;}echo QQLite_get('老虎'); //中文要 utf-8 编码的echo QQLite_get('大象');您搜索的解梦关键词:老虎