Jump to content

parsing twitter json request


eqpaisley

Recommended Posts

Hi all.  I am trying to get a list of the 3-5 most recent tweets from a feed.  Using Abrahams OAuth I've been able to do it, but what I get back is a wall of information.  I'm trying to figure out how to decode it and make sense of it so I can work with it (determine if a tweet is a reply or retweet, if its new, if it mentions someone specific, etc). 

<?php
session_start();
require_once("twitteroauth.php"); //Path to twitteroauth library
 
$twitteruser = "user_name_here";
$notweets = 10;
$consumerkey = "xxxxxx";
$consumersecret = "xxxxxxx";
$accesstoken = "xxxxxxxxxx";
$accesstokensecret = "xxxxxxxxxxxxxxxxxxx";
 
function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) {
  $connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret);
  return $connection;
}
 
$connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);
 
$tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser."&count=".$notweets);
 
echo json_encode($tweets);
?>
Link to comment
Share on other sites

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.