PHP code example of stavarengo / twitter-php-api-client

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

    

stavarengo / twitter-php-api-client example snippets


  $client = new \Sta\TwitterPhpApiClient\TwitterClient(null);

  $authResponse = $client->postOauth2Token($consumerKey, $consumerSecret);
  $response = $client->getUsersShow('@username', false, $authResponse->getEntityBearerToken());
  
  var_dump($response->hasError() ? $response->getEntityError() : $response->getEntityUser());
  

  $client = $container->get(\Sta\TwitterPhpApiClient\Client::class)
  
  $authResponse = $client->postOauth2Token($consumerKey, $consumerSecret);
  $response = $client->getUsersShow('@username', false, $authResponse->getEntityBearerToken());
  
  var_dump($response->hasError() ? $response->getEntityError() : $response->getEntityUser());
  

composer