PHP code example of utxo-one / twitter-ultimate-php

1. Go to this page and download the library: Download utxo-one/twitter-ultimate-php 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/ */

    

utxo-one / twitter-ultimate-php example snippets


use UtxoOne\TwitterUltimatePhp\Clients\TweetClient;

$client = new TweetClient(bearerToken: $_ENV['TWITTER_BEARER_TOKEN']);

$tweet = $client->getTweet('1272846378268347');

use UtxoOne\TwitterUltimatePhp\Clients\TweetClient;

$client = new TweetClient(
    apiKey: $_ENV['TWITTER_API_KEY'], 
    apiSecret: $_ENV['TWITTER_API_SECRET'], 
    accessToken: $_ENV['TWITTER_ACCESS_TOKEN'], 
    accessSecret: $_ENV['TWITTER_ACCESS_SECRET'],
);

$tweet = $client->tweet('Hello World!');

use UtxoOne\TwitterUltimatePhp\Clients\TweetClient;

$client = new TweetClient(bearerToken: $_ENV['TWITTER_BEARER_TOKEN']);
$tweet = $client->getTweet('1565628118001455105');

// Available Getter Methods.
$tweet->getId();
$tweet->getText();
$tweet->getCreatedAt();
$tweet->getAuthorId();
$tweet->getConversationId();
$tweet->getInReplyToUserId();
$tweet->getLang();
$tweet->getSource();
$tweet->isWithheld();
$tweet->getPublicMetricS();
$tweet->getReplySettings();
$tweet->getReferencedTweets();
$tweet->getEntities();
$tweet->getGeo();
$tweet->getContextAnnotations();
$tweet->isPossiblySensitive();
$tweet->getAttachements();

use UtxoOne\TwitterUltimatePhp\Clients\TweetClient;

$client = new TweetClient(bearerToken: $_ENV['TWITTER_BEARER_TOKEN']);
$tweets = $client->getTweets(['1565628118001455105', '1565999511536914433'])->all();

foreach($tweets as $tweet) {
  $tweet->getId();
  // ...
}


use UtxoOne\TwitterUltimatePhp\Clients\UserClient;

$client = new UserClient(bearerToken: $_ENV['TWITTER_BEARER_TOKEN']);

$user = $client->getUserByUsername('utxoone');
$user->getId();
$user->getName();
$user->getUsername();
$user->getCreatedAt();
$user->getDescription();
$user->getLocation();
$user->getPinnedTweetId();
$user->getProfileImageUrl();
$user->getUrl();
$user->isVerified();
$user->isProtected();
$user->getEntities();


use UtxoOne\TwitterUltimatePhp\Clients\UserClient;

$client = new UserClient(bearerToken: $_ENV['TWITTER_BEARER_TOKEN']);

$user = $client->getUserByUsername('utxoone');
$likedTweets = $client->getLikedTweets($user->getId())->all();

foreach ($likedTweets as $likedTweet) {
  $likedTweet->getId();
  $likedTweet->getText();
  // ...
}

use UtxoOne\TwitterUltimatePhp\Clients\UserClient;

$client = new UserClient(
    apiKey: $_ENV['TWITTER_API_KEY'], 
    apiSecret: $_ENV['TWITTER_API_SECRET'], 
    accessToken: $_ENV['TWITTER_ACCESS_TOKEN'], 
    accessSecret: $_ENV['TWITTER_ACCESS_SECRET'],
);

$user = $client->getUserByUsername('utxo_one');
$tweet = $client->follow($user->getId());



use UtxoOne\TwitterUltimatePhp\Clients\ListClient;

$client = new ListClient(bearerToken: $_ENV['TWITTER_BEARER_TOKEN']);

$list = $client->getList('64651656516516516');
$list->getId();
$list->getFollowerCount();
$list->getCreatedAt();
$list->getMemberCount();
$list->isPrivate();
$list->getDescription();
$list->getOwnerId();


use UtxoOne\TwitterUltimatePhp\Clients\ListClient;

$client = new ListClient(
    apiKey: $_ENV['TWITTER_API_KEY'], 
    apiSecret: $_ENV['TWITTER_API_SECRET'], 
    accessToken: $_ENV['TWITTER_ACCESS_TOKEN'], 
    accessSecret: $_ENV['TWITTER_ACCESS_SECRET'],
);

$list = $client->createList(
  name: 'My New List',
  description: 'My New List Description',
  private: false,
);

$list->getId();



use UtxoOne\TwitterUltimatePhp\Clients\SpaceClient;

$client = new SpaceClient(bearerToken: $_ENV['TWITTER_BEARER_TOKEN']);

$space = $client->getSpace('64651656516516516');
$space->getId();
$space->getTitle();
$space->getCreatedAt();
$space->getUpdatedAt();
$space->getHostIds();
$space->getState();
$space->isTicketed();
$space->getLand();
$space->getCreatorId();