前言:
“本项目提供了一个PHP星座运势查询接口,该接口对接了魅族日历的星座运势数据。需要注意的是,由于接口依赖于魅族日历,因此不能保证长期稳定可用。如果调用该接口的用户过多,魅族官方可能会修改接口规则,导致接口失效。建议开发者在使用时做好相应的异常处理和备用方案,以应对潜在的风险。”
请求示例
域名/xingzuo.php?msg=天秤座
返回示例
/*网站名称:汇站网*/
/*原文链接:https://www.huizhanii.com/?p=38750*/
<?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);
}
?>
转载请注明:汇站网 » PHP 星座运势接口 API 源码