hansman Posted June 4, 2011 Share Posted June 4, 2011 Hey guys, I'm working with a JSON that Twitter gave me... http://api.twitter.com/1/statuses/show/76626185060225024.json I would like to extract the Titter username ('name') and the tweet ('text'). For some reason I can't seem to get any of the objects to echo. Here is what I have.. $tweetid = '76626185060225024'; $jsonurl = "http://api.twitter.com/1/statuses/show/".$tweetid.".json"; $json = file_get_contents($jsonurl); $data = json_decode($json); // echo $jsonurl; //echo $data; // echo $json; //echo $data['0']['text']; // print_r($data); echo $data['0']->name; //$tweet = $data[0]->text; //$tweet = html_entity_decode($tweet); echo $twitterName; You can tell by the commenting that I have tried a lot of things. Thanks for the help in advance. Quote Link to comment https://forums.phpfreaks.com/topic/238361-problem-storing-through-json/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 4, 2011 Share Posted June 4, 2011 echo $data->user->name; echo $data->text; The print_r output, if you did it using the following line of code, so that you can easily see the data, would have helped - echo '<pre>',print_r($data,true),'</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/238361-problem-storing-through-json/#findComment-1224972 Share on other sites More sharing options...
jcbones Posted June 4, 2011 Share Posted June 4, 2011 echo $data->user->name; echo $data->text; The print_r output, if you did it using the following line of code, so that you can easily see the data, would have helped - echo '<pre>',print_r($data,true),'</pre>'; Or, it's to late, and I didn't really look at it to good!!! :'( Quote Link to comment https://forums.phpfreaks.com/topic/238361-problem-storing-through-json/#findComment-1224984 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.