J7mbo / twitter-api-php

The simplest PHP Wrapper for Twitter API v1.1 calls
MIT License
1.82k stars 800 forks source link

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

Open Cedric-IEF2I opened 7 years ago

Cedric-IEF2I commented 7 years ago

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 !

EwenH commented 7 years ago

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.

Cedric-IEF2I commented 7 years ago

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.