Download the PHP package spatie/twitter-labs without Composer

On this page you can find all versions of the php package spatie/twitter-labs. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package twitter-labs

PHP client for Twitter Labs endpoints

Latest Version on Packagist GitHub Tests Action Status Total Downloads

This package aims to implement some of the realtime endpoints exposed by Twitter's new API, as the old realtime Twitter streams are being deprecated.

Twitter Developer Labs is where you’ll have early access to new API endpoints, features and versions. We’ll use Labs to test out new ideas and invite our developer community to share their feedback to help shape our roadmap.

(from the Twitter Developer Labs website)

Under the hood this is using ReactPHP for everything async. Even though you can use the package with no knowledge of ReactPHP, it is recommended to familiarize yourself with its event loop concept.

If you're currently using our old twitter-streaming-api package, making the switch to this package should be easy.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

Usage

Currently, only the filtered stream endpoints are implemented. We accept PRs for the other features Twitter Labs exposes.

⚠ You'll need a Twitter Developer account with Twitter Dev Labs access enabled and an application that's enrolled in the filtered streams preview. Have a look at https://developer.twitter.com/en/labs.

Filtered streams overview

You can find the Twitter Labs filtered stream API docs here.

Twitter's filtered stream consists of one streaming endpoint that returns tweets in realtime and three endpoints to control what tweets are included in the realtime endpoint:

To use any of these filtered stream endpoints, you'll need a FilteredStream instance. Use the \Spatie\TwitterLabs\FilteredStream\FilteredStreamFactory to create this instance for you. The factory's create method takes your API credentials and optionally and event loop instance.

Basic usage: listening for Tweets

The event loop will start when calling start. All code after this call will not be executed unless something goes wrong and the event loop is stopped.

Managing filters/rules

Filters for realtime streams work slightly different in Twitter Labs compared to the old Twitter API. The main difference being that filter rules are actually stored per API key and are always applied when connecting to the stream. When adding or removing rules, these changes are also applied in realtime to the streaming endpoint without having to reconnect.

The following methods are available to manage filter rules:

You can either use async endpoints asynchronously (don't forget to run $filteredStream->run() to start the event loop) or use the regular endpoint synchronously.

Basic example that adds a rule:

Basic example that adds a rule asynchronously (can be combined with other tasks running in the same event loop):

Example that syncs rules by getting all existing rules, then deleting them and adding the new rules.

Listening for tweets

You can specify a callback to be executed when Twitter hears a tweet that passes your filter rules. The callback will be executed with just one parameter: \Spatie\TwitterLabs\FilteredStream\Responses\Tweet\Tweet $tweet. When everything is set-up you can use the connect() method to start listening.

As a shorthand, $filteredStream->start() is also available. It will connect to the realtime endpoint and start the event loop, even when no event loop was given. This is especially nice when you don't need the event loop anywhere else:

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of twitter-labs with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4
ext-json Version *
clue/buzz-react Version ^2.6.1
react/promise Version ^2.2
league/oauth2-client Version ^2.4
spatie/data-transfer-object Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package spatie/twitter-labs contains the following files

Loading the files please wait ....