If any of the following are applicable to your project, then the directory structure should follow industry best practices by being named the following.
bin/
build/
docs/
config/
src/
tests/
vendor/
Via Composer
$ composer require nir-arad/php-twitter-client
$ composer test
Below is a usage example to fetch a tweet and display its contents and attributes.
You will need to obtain both {api_key, api_secret} tokens for Oauth v1 based APIs, and a bearer token for Oauth v2 based APIs.
Store the credentials in a file (e.g. "project.json"). The file format is as follows:
{
"bearer_token": "AAAAAAAAAAAAAAAAAAAA...",
"api_key": "4FlE...",
"api_secret": "OewZ..."
}
Store the credentials in a file (e.g. "user.json"). The file format is as follows:
{
"oauth_token": "123...",
"oauth_token_secret": "wWby...",
"user_id": "987...",
"screen_name": "MyTwitterUser"
}
use NirArad\TwitterClient;
$p_cred = new TwitterClient\ProjectCredentials();
$p_cred->from_file($p_cred_file);
$u_cred = new TwitterClient\UserCredentials();
$u_cred->from_file($u_cred_file);
$client = new TwitterClient\TwitterClient();
$client->project_credentials = $p_cred;
$client->user_credentials = $u_cred;
$params = new TwitterClient\v1\Tweets\GetStatusesLookupQueryParams();
$params_array = array(
"id" => array(1326023218772144134)
);
$params->from_array($params_array)
$response = $client->GetStatusesLookup($params);
var_dump($response);
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
- [Nir Arad][link-author]
- [All Contributors][link-contributors]
The MIT License (MIT). Please see License File for more information.