Jump to content

Twitter JSON Search API


johnslater

Recommended Posts

I'm having some trouble with JSON, i'm new to it and i did my research and thought i had a good understanding of it. I was wrong.

 

Basically the code i have is below, i want to loop out results from the JSON search results from Twitter (in this example the profile picture) but something is wrong and i can find little help online. I hope i'm on the right lines, help would be great.

 

<?
$jsonurl = "http://search.twitter.com/search.json?q=twitter";
$json = file_get_contents($jsonurl,0,null,null);
$json_output = json_decode($json);

foreach ($json_output->results[0]->profile_image_url as $trend )
{
    echo $trend;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/195732-twitter-json-search-api/
Share on other sites

You're almost there, the only problem is your approach to the loop.

 

foreach ($json_output->results as $result)
{
    echo $result->profile_image_url;
}

 

Warning: Invalid argument supplied for foreach() in /mounted-storage/home114b/sub005/sc49493-NOAI/ifestapp.com/iphone/twitter.php  on line 6

 

still get the same error :(

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.