skip to Main Content

Suppose I have this text “retweet of tomgabi https://…” in a quoted_status, collected using https://api.twitter.com/1.1/statuses/user_timeline.json. When I open this link in a browser I can see a lot of information about the user (tweet, screen_name, description, etc). The URL change to https://twitter.com/wiltonpfilho/status/715320170655440896. How can I get, using the Twitter API, that user information (tweet, screen_name, description, etc) from this new URL. Can I access user information from id_str (in URL)?

2

Answers


  1. Check this Link

    So you REALLY don’t want to do this client side anymore. (Just went through numerous docs, and devs suggest to do all oAuth server-side)

    What you need to do:

    First: sign up on https://dev.twitter.com, and make a new application.

    Second: NOTE: Your Consumer Key / Secret along with Access Token / Secret

    Third: Download Twitter oAuth Library (In this case I used the PHP Library https://github.com/abraham/twitteroauth , additional library located here: https://dev.twitter.com/docs/twitter-libraries)

    Fourth: (If using php) Make sure cURL is enabled, if your running on a LAMP here’s the command you need:

    sudo apt-get install php5-curl
    

    Fifth: Make a new PHP file and insert the following: Thanks to Tom Elliot http://www.webdevdoor.com/php/authenticating-twitter-feed-timeline-oauth/

    <?php
    session_start();
    require_once("twitteroauth/twitteroauth/twitteroauth.php"); //Path to twitteroauth library you downloaded in step 3
    
    $twitteruser = "twitterusername"; //user name you want to reference
    $notweets = 30; //how many tweets you want to retrieve
    $consumerkey = "12345"; //Noted keys from step 2
    $consumersecret = "123456789"; //Noted keys from step 2
    $accesstoken = "123456789"; //Noted keys from step 2
    $accesstokensecret = "12345"; //Noted keys from step 2
    
    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);
    echo $tweets; //testing remove for production   
    ?>
    

    And boom, you’re done. I know this isn’t a pure js solution but again reading through the new Twitter API 1.1 docs they REALLY don’t want you to do this client site. Hope this helps!

    Login or Signup to reply.
  2. Use statuses/lookup.

    For example, https://api.twitter.com/1.1/statuses/lookup.json?id=715320170655440896

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search