【发布时间】:2019-03-25 08:25:10
【问题描述】:
我正在使用此代码在我的本地服务器中获取 Alexa 排名。但是当我上传到服务器并且出现错误时,此代码不起作用。
我正在使用的代码:
$uri = 'http://data.alexa.com/data?cli=10&dat=snbamz&url=';
$uri .= $domain;
$xml = simplexml_load_file($uri);
if (isset($xml->SD[1]->COUNTRY))
$country_rate = (int) $xml->SD[1]->COUNTRY->attributes()->RANK;
return($country_rate);
错误:
Warning: simplexml_load_file(): http://data.alexa.com/data?cli=10&dat=snbamz&url=tooc.ir:1: parser error : Start tag expected, '<' not found in /home2/mydesign/domains/tooc.ir/public_html/panel/2.php on line 5
Warning: simplexml_load_file(): Okay in /home2/mydesign/domains/tooc.ir/public_html/panel/2.php on line 5
Warning: simplexml_load_file(): ^ in /home2/mydesign/domains/tooc.ir/public_html/panel/2.php on line 5
Notice: Undefined variable: country_rate in /home2/mydesign/domains/tooc.ir/public_html/panel/2.php on line 13
这里是示例页面的link。
【问题讨论】:
-
可能会有所帮助:- stackoverflow.com/questions/20423902/…
-
那个url的响应好像只是
Okay,没有xml。 -
@Jerodev 但这是一个 xml link