twitter-api-php icon indicating copy to clipboard operation
twitter-api-php copied to clipboard

Do I need to call "new TwitterAPIExchange($settings)" before every API request ?

Open Cedric-IEF2I opened this issue 7 years ago • 2 comments

Hello, I am sorry if it's a stupid question, but do I need to call "new TwitterAPIExchange($settings)" before every API request ?

ie : Do I have to do : $API = new TwitterAPIExchange($settings); $result1 = json_decode( $API->setGetfield( "?user_id=1015908282&tweet_mode=extended&exclude_replies=true&include_rts=1&count=200" ) ->buildOauth( "https://api.twitter.com/1.1/statuses/user_timeline.json", "GET" ) ->performRequest(), true );

$API = new TwitterAPIExchange($settings); $result2 = json_decode( $API->setGetfield( "?slug=list&$setGetfield" ) ->buildOauth( "https://api.twitter.com/1.1/lists/statuses.json", "GET" ) ->performRequest(), true );


Or can I do : $API = new TwitterAPIExchange($settings);

$result1 = json_decode( $API->setGetfield( "?user_id=1015908282&tweet_mode=extended&exclude_replies=true&include_rts=1&count=200" ) ->buildOauth( "https://api.twitter.com/1.1/statuses/user_timeline.json", "GET" ) ->performRequest(), true );

$result2 = json_decode( $API->setGetfield( "?slug=list&$setGetfield" ) ->buildOauth( "https://api.twitter.com/1.1/lists/statuses.json", "GET" ) ->performRequest(), true );


Thanks for your help !

Cedric-IEF2I avatar Oct 02 '17 04:10 Cedric-IEF2I

Frederic, You should be able to call the settings a single time at the top unless you are using multiple twitter accounts. I don't have access to the code currently but testing both options should be simple to do.

EwenH avatar Oct 02 '17 21:10 EwenH

Thank you ExenH ! I already tested it on a small script and it seemed to work fine but I wanted to make sure because I am going to handle massive amounts of data.

Cedric-IEF2I avatar Oct 02 '17 22:10 Cedric-IEF2I