Get the Following using TwitterAPIExchange.php

1

I'm looking for a way to get the Following using the library

  

TwitterAPIExchange. php

I have managed to send tweets using this library in this way:

    require_once 'libs/twitteroauth.php';

            /** Set access tokens here - see: https://dev.twitter.com/apps/ **/ 
    // array de acceso
    $settings = array(
        'oauth_access_token' => 'xxxx',
        'oauth_access_token_secret' => 'xxxx',
        'consumer_key' => 'xxxxxx',
        'consumer_secret' => 'xxxxx',
    );

$url = "https://api.twitter.com/1.1/statuses/update.json";

// tipo de metodo
$requestMethod = 'POST';
$wp = array(CURLOPT_SSL_VERIFYPEER => false);

//tweet
$postfields = array('status' => 'Mi tweet enviado desde PHP');

// instancia de la conexion con twitter
$twitter = new TwitterAPIExchange ($settings);

// enviamos el tweet
$response = $twitter->buildOauth($url, $requestMethod)
                    ->setPostfields($postfields)
                    ->performRequest(true,$wp),$assoc = TRUE);

All good without problems my question is How to get the User list that I follow (Following) Using this library

    
asked by BotXtrem Solutions 24.09.2017 в 02:41
source

1 answer

1

It would only be necessary:

$url = 'https://api.twitter.com/1.1/friends/list.json';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
echo $twitter->buildOauth($url, $requestMethod)
             ->performRequest(); 

Likewise, the optional parameters that can be sent are (there are more):

  • count: By default 20 and maximum 200, number of users per page to obtain
  • cursor: By default -1, it is used to navigate between the results obtained (it allows to page the obtained results). Each time you make a query you will also get previous_cursor and next_cursor which you will use for navigation.

Example:

$url = 'https://api.twitter.com/1.1/friends/list.json';
$getfield = '?count=200&cursor=1333504313713126852'; // POR EJEMPLO
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
echo $twitter->setGetfield($getfield)
             ->buildOauth($url, $requestMethod)
             ->performRequest(); 

Remember that setGetfield is optional.

Reference:

answered by 24.09.2017 / 03:19
source