PHP code example of mingalevme / twapponator

1. Go to this page and download the library: Download mingalevme/twapponator 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/ */

    

mingalevme / twapponator example snippets




// Obtain Bearer Token (if needed)
$token = \Twapponator\Twapponator::obtainBearerToken('consumer_key', 'consumer_secret');

// Now you can cache it for future use
$someCacheStorage->set('twitter_bearer_token', $token);


// Init Twapponator Object
$twapponator = new \Twapponator\Twapponator($token);

// Request API Endpoint data
try {
    $data = $twapponator->request('https://api.twitter.com/1.1/statuses/show.json?id=' . $someTweetId);
} catch (\Twapponator\Exception $e) {
    echo $e->getMessage();
    exit();
}

// For some endpoints there are shortcuts.
// See list of available shortcuts in \Twapponator\Client class source code.
// Next row is equal to $twapponator->request('https://api.twitter.com/1.1/statuses/show.json?id=' . $someTweetId);
$data = $twapponator->status($someTweetId);

echo $response;

# Install Composer
curl -sS https://getcomposer.org/installer | php

# Add Twapponator as a dependency
php composer.phar 



"php": ">=5.3.0"
"ext-curl": "*"