1. Go to this page and download the library: Download coderjerk/elephant-bird library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
coderjerk / elephant-bird example snippets
$credentials = array(
//these are values that you can obtain from developer portal:
'consumer_key' => xxxxxx, // identifies your app, always needed
'consumer_secret' => xxxxxx, // app secret, always needed
'bearer_token' => xxxxxx, // OAuth 2.0 Bearer Token requests
//this is a value created duting an OAuth 2.0 with PKCE authentication flow:
'auth_token' => xxxxxx // OAuth 2.0 auth token
//these are values created during an OAuth 1.0a authentication flow to act ob behalf of other users, but these can also be obtained for your app from the developer portal in order to act on behalf of your app.
'token_identifier' => xxxxxx, // OAuth 1.0a User Context requests
'token_secret' => xxxxxx, // OAuth 1.0a User Context requests
);
$twitter = new BirdElephant($credentials);
use Coderjerk\BirdElephant\BirdElephant;
//your credentials, should be passed in via $_ENV or similar, don't hardcode.
$credentials = array(
'consumer_key' => xxxxxx,
'consumer_secret' => xxxxxx,
'bearer_token' => xxxxxx,
// if using oAuth 2.0 with PKCE
'auth_token' => xxxxxx // OAuth 2.0 auth token
//if using oAuth 1.0a
'token_identifier' => xxxxxx,
'token_secret' => xxxxxx,
);
//instantiate the object
$twitter = new BirdElephant($credentials);
//get a user's followers using the handy helper methods
$followers = $twitter->user('coderjerk')->followers();
//pass your query params to the methods directly
$following = $twitter->user('coderjerk')->following([
'max_results' => 20,
'user.fields' => 'profile_image_url'
]);
//tweet something
$tweet = (new \Coderjerk\BirdElephant\Compose\Tweet)->text(".@coderjerk is so cool");
$twitter->tweets()->tweet($tweet);
// You can also use the sub classes / methods directly if you like:
$user = new UserLookup($credentials);
$user = $user->getSingleUserByID('2244994945', null);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.