tags:

views:

15

answers:

1
<?php
header('Content-type: application/json');
$json = file_get_contents("http://twitter.com/status/user_timeline/lindsaylohan.json?count=1");
$temp = json_decode($json);
$array = Array();
$array[] = $temp;
echo json_encode($array);
?>

I have a JSON parser in my iphone app. I'm using the above PHP code to try and search Twitter. Can anyone tell me the best way to search the web or get twitter results and return them to my app? I've tried YQL but could not get on with it. All i want is raw text returned to my app. Almost like RSS feeds

A: 

The ability to search is built right into the Twitter API. See the documentation for the search method here: http://apiwiki.twitter.com/Twitter-Search-API-Method:-search

For example, you could search for StackOverflow at this address: http://search.twitter.com/search.json?q=twitter

What do you mean when you say you want "raw text" though? The contents of a tweet are inherently structured, so Twitter does not provide an API that returns an unstructured copy of one. Is there a particular reason why decoding the JSON (or ATOM) formats doesn't work for your purpose?

VoteyDisciple
Ok, maybe using twitter was misleading, I'd rather return google news rss feeds to my app but via json to a php page then back to my app, but I need to php/json bit sorted so the json parser I have on the iPhone can interpret it right
benhowdle89