1. Go to this page and download the library: Download mfrost503/snaggle 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/ */
mfrost503 / snaggle example snippets
use Snaggle\OAuth1\Client\Credentials\AccessCredentials;
use Snaggle\OAuth1\Client\Credentials\ConsumerCredentials;
use Snaggle\OAuth1\Client\Signatures\HmacSha1;
use Snaggle\OAuth1\Client\Signatures\Plaintext;
use Snaggle\OAuth1\Client\Header\Header;
// first we need to represent our tokens, these should be stored securely
$consumer = new ConsumerCredentials('CONSUMER_KEY', 'CONSUMER_SECRET');
$access = new AccessCredentials('ACCESS_TOKEN', 'ACCESS_SECRET');
$signature = new HmacSha1($consumer, $access)
->setResourceURL('https://api.example.com/v1/users')
->setHttpMethod('get');
$header = new Header();
$header->setSignature($signature);
$header->createAuthorizationHeader();
$signature = new Plaintext($consumer, $access);
$header = new Header();
$header->setSignature($signature);
$authorizationHeader = $header->createAuthorizationHeader();
$client = new Client();
$client->get('https://api.example.com/v1/users', [
'headers' => ['Authorization' => $authorizationHeader]
]);