A PHP library for consuming data from the Twitter Streaming API v1.1 via OAuth.
This library aims for PSR-1, PSR-2 and PSR-4 standards compliance.
composer require "impensavel/floodgate"
<?php
require 'vendor/autoload.php';
use Impensavel\Floodgate\Floodgate;
use Impensavel\Floodgate\FloodgateException;
try {
$config = [
'oauth' => [
'consumer_key' => 'OADYKJgKogkkYtzdIKLZEq77Z',
'consumer_secret' => 'Z0mImnDYzH3Tbe4eyQLQEA0lyzXsWFmmZsQTAYHtBrSBX04bKK',
'token' => '456786512-D4MnYQ3U74wd40zXHRHa495wl00ogOyhJu9iqEhz',
'token_secret' => 'EUyz6MawvBlabLAb2gY6fgyTagtMMYny7GmzKfulGo3Di',
],
];
$floodgate = Floodgate::create($config);
// Data handler
$handler = function ($message)
{
// dump each message from the stream
var_dump($message);
};
// API endpoint parameter generator
$generator = function ()
{
return [
'track' => 'php',
];
};
// consume the Twitter Streaming API filter endpoint
$floodgate->filter($handler, $generator);
} catch (FloodgateException $e) {
// handle exceptions
}
The MIT License (MIT). Please see License File for more information.