Parsing Twitter Search Results using PHP using XMLReader
I'm using PHP curl to obtain an XML string for parsing and I'd like to parse with XMLReader. I can't find any good examples of how to iterate through ea开发者_运维问答ch of the entries while storing some of the nodes (user, title, updated) as variables. Then I want to do something with the variables and move onto the next entry. I also need to be able to check if a node is empty (to be able to identify which entries have geo data).
An example xml feed would look like this.
Thanks.
Try using a PHP client built for Twitter, such as - http://code.google.com/p/twitter-php/ Then you don't have to parse XML etc.
Using this library, your code for search page would look like
The search() method provides searching in twitter statuses:
$results = $twitter->search('#nette');
The returned result is a PHP array:
foreach ($results as $result) {
echo "message: ", $result->text;
echo "posted at " , $result->created_at;
echo "posted by " , $result->form_user;
}
精彩评论