How to collect tweets and followers from the API?

Asked

Viewed 180 times

-1

Well guys I’m here again researching on the api’s on 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 the tweets and followers, As far as I know the language to do this is in php, I do not know much, but I think it is a more common language. Does anyone know any clear tutorial that might help? or any snippets of code that might help? Grateful.

  • The most important thing was missing. In what language? It puts a context of what you want to do. Read [tour] and [Ask].

  • Sorry man, I think it’s clearer now.

  • Buddy take a look at this guy https://storm.apache.org/ I’m using it in my tcc. It’s pretty cool!

1 answer

1


Hi, I’m Luís, evangelistic developer of Twitter here in Brazil. Twitter has multiple endpoints in the API that let you access what you need. It wasn’t clear which language you want to use, but I’ll give the example in PHP, since you mentioned it. To connect in the API you need:

  1. Create an app in apps.twitter.com
  2. Get 4 access keys: consumer_key, consumer_secret, access_token_key, access_token_secret (in your app on apps.twitter.com)
  3. Configure these keys in the library you will use:

The most recommended library for PHP is tmhOAuth, see an example of how to search for tweets, available at https://github.com/themattharris/tmhOAuthExamples/blob/master/cli/search.php:

<?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 from a user, as shown in the example from the same repository: https://github.com/themattharris/tmhOAuthExamples/blob/master/cli/followings.php

I suggest taking a look at the following references:

  • Luiz Boa Noite, I’m trying to understand how to work on this issue but I still don’t understand how to make the request by php, I know I need the Keys and tokens, but I still haven’t been able to collect anything.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.