【发布时间】:2012-02-04 13:48:22
【问题描述】:
我只想用该代码读出 google 天气 api xml,但它返回 500。任何想法为什么?
<?php
$url = "http://www.google.com/ig/api?weather=Moskva&hl=en";
$xml = simplexml_load_string(utf8_encode(file_get_contents($url)));
echo $xml->weather->current_conditions->temp_c->attributes()->data;
?>
【问题讨论】:
-
为我工作没有任何错误....日志中有什么?输出 "2" 但可以 print_r 整个
$xml -
当您开始注释行时会发生什么?当您在 url 上调用文件获取内容时会发生什么?当您尝试调试此代码时会发生什么?
-
一切正常,直到我这样做 echo $xml->weather->current_conditions->temp_c->attributes()->data;
-
@user1005619 将 echo 行更改为
print_r($xml);会返回什么? -
为什么投反对票?所有反对者至少会发表评论......