【问题标题】:Twitter XML feed推特 XML 提要
【发布时间】:2025-11-29 14:50:02
【问题描述】:

我刚刚为获取 xml 的状态编写了 twitter 提要。我想知道是否还有提及和主题标签的 XML 链接

【问题讨论】:

标签: php xml twitter


【解决方案1】:

对于推特提及:

function curlRequest($url, $post) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_USERPWD, "username:password"); curl_setopt($curl, CURLOPT_HEADER, FALSE); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_TIMEOUT, 20); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); // we are not using the $post variable yet, but stay tuned! if ($post) { curl_setopt($curl, CURLOPT_POST, TRUE); curl_setopt($curl, CURLOPT_POSTFIELDS, $post); } return curl_exec($curl); } //then call this function as: $contents= curlRequest(“http://twitter.com/statuses/mentions.xml”, FALSE); $xml= new SimpleXMLElement($contents); foreach($xml->status as $status) { echo "<li>$status->text</li>"; }

【讨论】: