Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.