A very small package providing some functions to access the Twitter V2 API.
You can install the package via composer:
composer require plugrbase/laravel-twitter-api
Optionally publish the config file of this package:
php artisan vendor:publish --provider="Plugrbase\TwitterApi\TwitterApiServiceProvider"
Add the following environment variables.
TWITTER_API_CONSUMER_KEY=
TWITTER_API_CONSUMER_KEY_SECRET=
TWITTER_BEARER_TOKEN=
TWITTER_ACCESS_TOKEN=
TWITTER_TOKEN_SECRET=
TWITTER_API_URL=
$twitterApi = new TwitterApi($bearerToken, $oAuthCredentials);
- Create a new instance. If the oauth credentials are not passed, then the application config variables we'll be used instead (if provided).
$twitterApi->tweet()->get($tweetId)
- Return a single Tweet.$twitterApi->tweet()->get($tweetId, ['expansions' => 'referenced_tweets.id.author_id','place.fields' => 'contained_within,country']);
- Return a single Tweet with optional query parameters.$twitterApi->tweet()->getMany([$tweetId1, $tweetId2])
- Return multiple Tweets.$twitterApi->tweet()->create($params)
- Create a Tweet. ex $params = ["text": "Hello World!"];
$twitterApi->user()->get($userId)
- Return a single user.$twitterApi->user()->get($userId, , ['user.fields' => 'created_at']);
- Return a single user with optional query parameters.$twitterApi->user()->getMany([$userId1, $userId2])
- Return multiple users.$twitterApi->user()->getByUsername($username)
- Return a single user by username.$twitterApi->user()->getManyByUsername([$username1, $username2])
- Return multiple users by username.$twitterApi->user()->getFollowers($userId)
- Return all the followers of a user.$twitterApi->user()->getFollowers($userId, ['max_results' => 5])
- Return the five earliest followers of a user.$twitterApi->user()->getTweets($userId)
- Return all the tweets of a user. By default, the most recent ten Tweets are returned per request. Using pagination, the most recent 3,200 Tweets can be retrieved.$twitterApi->user()->getTweets($userId, ['max_results' => 5])
- Return the five earliest tweets of a user.
composer test
Please see CHANGELOG for more information what has changed recently.
The MIT License (MIT). Please see License File for more information.