我想从 twitter 获取状态以显示在我的网站上。
这是代码
<?php
function getTwitterStatus($userid){
$url = "https://api.twitter.com/1/statuses/user_timeline/$userid.xml?
count=1&include_rts=1callback=?";
$xml = simplexml_load_file($url) or die("could not connect");
foreach($xml->status as $status){
$text = $status->text;
}
echo $text;
}
getTwitterStatus("soksovat");
?>
我想从 userid = "soksovat" 获得 1 个状态,但是当我运行上述命令时,会出现两个警告:
- 警告:simplexml_load_file(https://api.twitter.com/1/statuses/user_timeline/soksovat.xml?count=1&include_rts=1callback=?)[function.simplexml-load-file]:未能打开流:HTTP请求失败!HTTP/1.0 410 Gone in .......... 第 6 行
- 警告:simplexml_load_file() [function.simplexml-load-file]:I/O 警告:无法加载外部实体“ https://api.twitter.com/1/statuses/user_timeline/soksovat.xml?count=1&include_rts= 1回调=?” 在 ........第 6 行计数未连接
任何人都可以帮助解决这个问题吗?几天前我被它困住了。
预先感谢。