Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

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

Closed
Cedric-IEF2I opened this issue Oct 2, 2017 · 2 comments

Comments

@Cedric-IEF2I
Copy link

Cedric-IEF2I commented Oct 2, 2017

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
Copy link

EwenH commented Oct 2, 2017

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
Copy link
Author

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.

@J7mbo J7mbo closed this as completed Jan 15, 2025
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants