Switch between Twitter API v1.1 and v2
mainBy default, the package uses API v1.1.
To set API v2 as the global default, set TWITTER_API_VERSION=2 in your .env file.
To switch versions fluently in your code:
- Use
Twitter::forApiV2()to get an instance of the v2 client. - Use
Twitter::forApiV1()to get an instance of the v1 client.
Note: It is safe to call Twitter::forApiV1() on either a v1 or v2 client instance.
// If default is v1.1, get v2 client
$v2Client = Twitter::forApiV2();
// If default is v2, get v1 client
$v1Client = Twitter::forApiV1();