PHP星座运势接口API源码
源码介绍
PHP星座运势接口API源码,接口是对接的魅族日历,不保证能长期使用,可能调用的人多了官方就改规则了。
请求示例
域名/xingzuo.php?msg=天秤座
返回示例
<?php
$name=$_GET["msg"];//需要查询的星座
$hh=$_GET["hh"]?:"\n";//换行符号(默认\n)
if($name==""){exit("抱歉,输入为空。");}
$name=str_replace('座','',$name);
$jk=Array(
"白羊"=>"1",
"金牛"=>"2",
"双子"=>"3",
"巨蟹"=>"4",
"狮子"=>"5",
"处女"=>"6",
"天秤"=>"7",
"天蝎"=>"8",
"射手"=>"9",
"摩羯"=>"10",
"水瓶"=>"11",
"双鱼"=>"12");
$l=$jk[$name];
if($l==""){
exit("不存在此类型,请查证后重试。");}
$z=file_get_contents("http://cal.meizu.com/android/unauth/horoscope/gethoroscope.do?type=".$l."&date=".date("Y-m-d")."&searchType=0");
$z=myTrim($z);
$p=preg_match_all('/{"contentAll":"(.*?)","contentCareer":"(.*?)","contentFortune":"(.*?)","contentHealth":"(.*?)","contentLove":"(.*?)","contentTravel":"(.*?)","date":(.*?),"direction":"(.*?)","enemies":"(.*?)","friends":"(.*?)","horoscopeType":(.*?),"id":(.*?),"lucklyColor":"(.*?)","lucklyTime":"(.*?)","mark":(.*?),"numbers":(.*?),"pointAll":(.*?),"pointCareer":(.*?),"pointFortune":(.*?),"pointHealth":(.*?),"pointLove":(.*?),"pointTravel":(.*?),"shorts":"(.*?)"}/',$z,$z);
if($p==0){exit("抱歉,获取出错。");}
$zt=$z[1][0];//整体运势
$sy=$z[2][0];//事业运势
$cf=$z[3][0];//财富运势
$aq=$z[5][0];//爱情运势
$fw=$z[8][0];//贵人方位
$py=$z[10][0];//贵人星座
$ys=$z[13][0];//幸运颜色
$sz=$z[16][0];//幸运数字
$ts=$z[23][0];//提示
echo "星座:".$name."".$hh."";
echo "贵人方位:".$fw."".$hh."";
echo "贵人星座:".$py."".$hh."";
echo "幸运数字:".$sz."".$hh."";
echo "幸运颜色:".$ys."".$hh."";
echo "爱情运势:".$aq."".$hh."";
echo "财富运势:".$cf."".$hh."";
echo "事业运势:".$sy."".$hh."";
echo "整体运势:".$zt."".$hh."";
echo "提示:".$ts."";
function myTrim($str)
{
$search = array(" "," ","\n","\r","\t");
$replace = array("","","","","");
return str_replace($search, $replace, $str);
}
?>
阅读剩余
版权声明:
作者:小马
链接:https://www.xiaomaw.cn/581.html
来源:小马博客
文章版权归作者所有,未经允许请勿转载。
作者:小马
链接:https://www.xiaomaw.cn/581.html
来源:小马博客
文章版权归作者所有,未经允许请勿转载。
THE END