1. Go to this page and download the library: Download jkudish/plume 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/ */
jkudish / plume example snippets
use Plume\Facades\X;
// Post a tweet
$post = X::createPost('Hello from Plume!');
// Search recent tweets
$results = X::searchRecent('laravel');
foreach ($results->data as $post) {
echo "{$post->text}\n";
}
// Get your profile
$me = X::me();
echo $me->publicMetrics->followersCount;
// From credentials array or a model implementing HasXCredentials
$client = X::forUser($user);
// Inject user ID directly to skip the /me API call
$client = X::forUser($credentials)->withUser('12345');
// Or pass a User DTO
$client = X::forUser($credentials)->withUser($userDto);
// All calls auto-resolve the user ID
$client->like('tweet-id');
$client->bookmark('tweet-id');
$client->followers();
$client->userTimeline(maxResults: 20);
use Plume\Contracts\HasXCredentials;
class User extends Authenticatable implements HasXCredentials
{
public function toXCredentials(): array
{
return [
'access_token' => $this->x_access_token,
'refresh_token' => $this->x_refresh_token,
'expires_at' => $this->x_token_expires_at,
];
}
}
use Plume\Facades\X;
it('creates a post', function () {
$fake = X::fake();
X::createPost('Hello from tests!');
$fake->assertPostCreated('Hello');
$fake->assertCalledTimes('createPost', 1);
});
it('tracks interactions', function () {
$fake = X::fake();
X::like('user-1', 'tweet-1');
X::follow('user-1', 'target-1');
$fake->assertLiked('tweet-1');
$fake->assertFollowed('target-1');
});
it('stubs return values', function () {
$fake = X::fake();
$fake->shouldReturn('searchRecent', new PaginatedResult(
data: [new Post(id: '1', text: 'Stubbed')],
resultCount: 1,
));
$results = X::searchRecent('test');
expect($results->data[0]->text)->toBe('Stubbed');
});
bash
# Your profile
php artisan plume:me
# Post a tweet
php artisan plume:post --text="Hello from the CLI!"
# Search
php artisan plume:search "laravel" --max-results=20
# Your home timeline
php artisan plume:home --max-results=10 --format=json
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.