Download the PHP package rbadillap/twitterstreaming without Composer

On this page you can find all versions of the php package rbadillap/twitterstreaming. 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 twitterstreaming

TwitterStreaming

TwitterStreaming is a new PHP client that you can use to connect to the Twitter Streaming API and retrieve data in real-time. Throughout this document we'll see that its usage is simple, which can facilitate their integration with multiples systems/workflows.


Installation

TwitterStreaming PHP is a Composer package. It will install the package and its dependencies. The main dependency is Guzzle which is a PHP HTTP Client.

To install via composer, run the following command.

composer require rbadillap/twitterstreaming

You will need to create a Twitter Application. Follow its indications to get the keys.

TwitterStreaming PHP suggests to use PHP DotEnv by Vance Lucas to store you Twitter Application credentials, and keep separately from the code. If you wanna use it, you can include it in your package.json typing:

composer require vlucas/phpdotenv

Then create an .env file in the root of your project and put the values that you will see in: https://apps.twitter.com/app/[YOUR_APP_ID]/keys.

Elsewhere if you won't use this library, you should provide those credentials in the code at the moment you instance the Tracker class (take a look the file: WithoutDotEnv.php located in the examples folder). Also, if you wanna provide the credentials despite that you are already using the DotEnv library, you just need to provide those credentials through the instance creation and TwitterStreaming PHP will prioritize that.

TwitterStreaming PHP will throw an error if were unable to find the .env file or the Twitter credentials are invalid.

Features

How it works

After give the composer the authority to download the package and generate the autoloader, you will be able to use the namespaces of TwitterStreaming.

Something like this.

Obviously, we would like to add more configurations. So you need to work close with the official documentation of Twitter Streaming API: https://dev.twitter.com/streaming/overview to understand how this app works.

Endpoints

First of all, something very important to understand, is that Twitter gives to you 3 official endpoints.

In TwitterStreaming PHP you can set an endpoint using the method endpoint on this way:

Note:

  • If you see in the official documentation, there is another API to interact deeper with Twitter, to make searches, read user profile information or post tweets for example, called REST API, which doesn't belong to this package due there is a lot of good clients already written.
  • In some cases the second argument type won't be necessary.

How to define an endpoint

Depending of the endpoint that you're going to work, you may define the type as well. For example, the Public Endpoint.

See: https://dev.twitter.com/streaming/public

As you can see, this endpoint, provides 3 types: filter, sample and firehose. At this moment, the only functional types are filter and sample. The type firehose requires special permission from Twitter.

To define this endpoint you can do something like this;

Also you can add the class directly if you want.

Or the User Endpoint, that doesn't need an specific type.

If you notice, we don't need to specify any URL or any other feature to run an specific endpoint. We have covered all in our library :)

Parameters

After defining the endpoint, you can continue with the parameters that you'd like to send to Twitter.

An important point to understand is that you can set the parameters based on what Twitter allows to you to use.

For example, if you wants filter tweets using the Public Endpoint and the Filter type, you can see a list of available parameters here: https://dev.twitter.com/streaming/reference/post/statuses/filter you can add all of those parameters in TwitterStreaming PHP. How?

You can filter by two or more hashtags as well, for example.

This will convert the track to something like: #twitter OR #facebook OR #instagram

If you wanna filter tweets with all those hashtags (instead of OR use AND) just put the words in a same line.

See: https://dev.twitter.com/streaming/overview/request-parameters

Track

After define the endpoint and parameters, you will be able to track the tweets. TwitterStreaming PHP will throw to you every single tweet, and you can manipulate them as your convenience.

Just use the method track.

Disconnect

In some cases you may need to disconnect from the stream after meeting some criteria. In this case you can use the disconnect() method from inside the track() closure method. To do so you can pass a second optional $request argument to the closure. Here is the same example from above with a disconnect() implemented.

More examples

We have attached a folder called examples with samples about how TwitterStreaming PHP works in different scenarios.

Contributing

Use the same workflow as many of the packages that we have here in Github.

  1. Fork the project.
  2. Create your feature branch with a related-issue name.
  3. Try to be clear with the code committed and follow the PSR-2 Coding Style Guide.
  4. Run the tests (and create your new ones if necessary).
  5. Commit and push the branch.
  6. Create the Pull Request.

All versions of twitterstreaming with dependencies

PHP Build Version
Package Version
Requires guzzlehttp/guzzle Version 6.*
guzzlehttp/oauth-subscriber Version ^0.3.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 rbadillap/twitterstreaming contains the following files

Loading the files please wait ....