Jump to content

Problem storing through JSON


hansman

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/238361-problem-storing-through-json/
Share on other sites

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!!!  :'(

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.