impensavel / floodgate
A PHP library for consuming data from the Twitter Streaming API v1.1 via OAuth
v2.0.2
2015-08-25 20:51 UTC
Requires
- php: >=5.4.0
- guzzlehttp/guzzle: ~5.0
- guzzlehttp/oauth-subscriber: 0.2.*
- guzzlehttp/retry-subscriber: ~2.0
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is auto-updated.
Last update: 2024-11-10 04:17:25 UTC
README
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.
Requirements
Installation
composer require "impensavel/floodgate"
Basic usage example
<?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 }
Class documentation
Twitter Documentation
License
The MIT License (MIT). Please see License File for more information.