How to collect tweets and followers through the API?

-1

Well here I am again researching api's in social networks, I'm starting twitter now and I'm having some difficulties, I need to collect profiles (id / name) and along with the profile I have to collect tweets and followers, so far as I know the language that's supposed to do this is in php, I do not know much, but I think it's a more common language. Does anyone know of any clear tutorials that can help? or some snippet of code that might help? Thankful.

    
asked by anonymous 20.08.2015 / 02:42

1 answer

1

Hello, I'm Luís, Twitter evangelist here in Brazil. Twitter has several endpoints in the API that allow you to access what you need. It was not clear what language you want to use, but I'll set the example in PHP, since you mentioned it. To connect to the API you need:

  • Create an app on apps.twitter.com
  • Get the 4 access keys: consumer_key, consumer_secret, access_token_key, access_token_secret (in your app at apps.twitter.com)
  • Configure these keys in the library you are going to use:
  • The most recommended library for PHP is tmhOAuth, see an example of how to search for tweets, available at link :

    <?php
    require __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'tmhOAuthExample.php';
    $tmhOAuth = new tmhOAuthExample();
    $code = $tmhOAuth->apponly_request(array(
      'method' => 'GET',
      'url' => $tmhOAuth->url('1.1/search/tweets'),
      'params' => array(
        'q' => 'tmhoauth'
      )
    ));
    $tmhOAuth->render_response();
    

    You can also get the graph of a user, as the example from the same repository shows: link

    I suggest taking a look at the following references:

    20.08.2015 / 16:47