All Projects → mineur → twitter-stream-api

mineur / twitter-stream-api

Licence: MIT license
🐤 Another Twitter stream PHP library to retrieve filtered tweets on hot.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to twitter-stream-api

godsend
A simple and eloquent workflow for streaming messages to micro-services.
Stars: ✭ 15 (+36.36%)
Mutual labels:  streaming-api, streaming-data
mxfactorial
a payment application intended for deployment by the united states treasury
Stars: ✭ 36 (+227.27%)
Mutual labels:  streaming-api, streaming-data
transit
Massively real-time city transit streaming application
Stars: ✭ 20 (+81.82%)
Mutual labels:  streaming-api, streaming-data
Swim
Distributed software platform for building stateful, massively real-time streaming applications.
Stars: ✭ 368 (+3245.45%)
Mutual labels:  streaming-api, streaming-data
twitterstream
Twitter Streaming API Example with Kafka Streams in Scala
Stars: ✭ 49 (+345.45%)
Mutual labels:  twitter-streaming-api
Guzzle Swoole
让基于 Guzzle 的项目完美无缝兼容 Swoole 协程,支持:Guzzle、Elasticsearch client——来自宇润 PHP 全家桶
Stars: ✭ 143 (+1200%)
Mutual labels:  guzzle
Guzzle Advanced Throttle
A Guzzle middleware that can throttle requests according to (multiple) defined rules. It is also possible to define a caching strategy, e.g. get the response from cache when the rate limit is exceeded or always get a cached value to spare your rate limits. Using wildcards in host names is also supported.
Stars: ✭ 120 (+990.91%)
Mutual labels:  guzzle
php-server-sdk
LaunchDarkly Server-side SDK for PHP
Stars: ✭ 31 (+181.82%)
Mutual labels:  guzzle
Guzzle Rate Limiter Middleware
A rate limiter middleware for Guzzle
Stars: ✭ 94 (+754.55%)
Mutual labels:  guzzle
you-cant-download-this-image
Downloading images from the web is as easy as right clicking them and selecting "Save image as..", right? Well, not anymore xD
Stars: ✭ 339 (+2981.82%)
Mutual labels:  streaming-data
twitter-stream-rs
A Rust library for listening on Twitter Streaming API.
Stars: ✭ 66 (+500%)
Mutual labels:  twitter-streaming-api
Crawler
An easy to use, powerful crawler implemented in PHP. Can execute Javascript.
Stars: ✭ 2,055 (+18581.82%)
Mutual labels:  guzzle
oauth2-middleware
PSR7 middleware that uses league/oauth2-client to authenticate outgoing requests
Stars: ✭ 21 (+90.91%)
Mutual labels:  guzzle
Snorlax
A lightweight REST client that gives you full control of your resources
Stars: ✭ 129 (+1072.73%)
Mutual labels:  guzzle
guzzle-psr18-adapter
A simple guzzle PSR-18 adapter
Stars: ✭ 13 (+18.18%)
Mutual labels:  guzzle
Microservices With Lumen
A Lumen based microservice ready to deploy with guzzle for consumption of api and OAuth 2
Stars: ✭ 115 (+945.45%)
Mutual labels:  guzzle
download-using-streaming-response-body
An example for streaming large files in chunks using StreamingResponseBody in Spring MVC
Stars: ✭ 62 (+463.64%)
Mutual labels:  streaming-data
frizzle
The magic message bus
Stars: ✭ 14 (+27.27%)
Mutual labels:  streaming-data
Guzzle Services
Provides an implementation of the Guzzle Command library that uses Guzzle service descriptions to describe web services, serialize requests, and parse responses into easy to use model structures.
Stars: ✭ 226 (+1954.55%)
Mutual labels:  guzzle
JavaSE8-Features
Take a tour of the new features in Java SE 8, the platform designed to support faster and easier Java development. Learn about Project Lambda, a new syntax to support lambda expressions in Java code; the new Stream API for processing collections and managing parallel processing; the DateTime API for representing, managing and calculating date an…
Stars: ✭ 51 (+363.64%)
Mutual labels:  streaming-api

Twitter Streaming API

License Build Status Code Climate Latest Unstable Version Total Downloads

Another Twitter Stream PHP library. For now it just works on public stream, using the filter method.

Index

Installation

composer require mineur/twitter-stream-api:dev-master

Basic initialization

Instantiate the GuzzleHttpClient adapter with your Twitter api tokens. And start consuming Twitter's Stream with some keywords! :)
If you don't have your Twitter API credentials, check this: How to get your twitter access tokens

use Mineur\TwitterStreamApi\Http\GuzzleStreamClient;
use Mineur\TwitterStreamApi\PublicStream;

$streamClient = new GuzzleStreamClient(
    'consumer_key',
    'consumer_secret',
    'access_token',
    'access_token_secret'
);
PublicStream::open($streamClient)
    ->listenFor([
        'your',
        'keywords',
        'list'
    ])
    ->consume();

Working with the Twitter Stream you cannot open two stream lines with the same account. You should create another app account and raise a new instance of this library.

Callback method

You can also use a callback instead, if you want to modify the original output:

use Mineur\TwitterStreamApi\Tweet;

PublicStream::open($streamClient)
    ->listenFor([
        'your',
        'keywords',
        'list'
    ])
    ->do(function(Tweet $tweet) {
        echo "$tweet->getUser() tweeted: $tweet->getText()";
    });

Filtering tweets by user ID

In this example you'll only get the tweets of a user corresponding to its ID.

$myTwitterId = '1234567';
PublicStream::open($streamClient)
    ->tweetedBy([
        $myTwitterId
    ])
    ->consume();

Filtering keywords by language

In this example you'll only get the tweets on your keywords list write in spanish language.

PublicStream::open($streamClient)
    ->listenFor([
        'keywords',
        'list'
    ])
    ->setLanguage('es')
    ->consume();

The Tweet object

Once you receive the output from the PublicStream, let's say when you are using the do callback function, the output will always be an hydrated Tweet value object.
You can access it with the following methods:

  • Using getters:
// Get specific data from the object
$tweet->getText();
  • As an array:
// Transform object to an array, then access to the data
$aTweet = $tweet->toArray();
$aTweet['text'];
  • Serialized:
// A complete serialized object to enqueue it, for example
$tweet->serialized();

Integrations

For Symfony integrations you can refer to this bundle: Mineur Twitter Stream Api Bundle

Run tests

composer install
./bin/phpunit

To check the coverage just add:

./bin/phpunit --coverage-text

Todo's

  • STREAMING_ENDPOINT should be changed by client, using simple string injection
  • Add links of the filters in documentation
  • Test the first version of this library using Unit testing
  • Handle when a user removes a tweet on the fly.
  • Add filter_level feature
  • Add track location feature
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].