There is no license information available for the latest version (2.7.1) of this package.

2.7.1 2016-08-22 09:42 UTC


Build Status

This is the official PHP library for accessing Datasift. See the examples folder for some simple example usage.

Getting Started

To get started choose one of our quick start guides:

Simple example

This example looks for anything that contains the word "datasift" and simply prints the content to the screen as they come in.

  // Load the library (If you're using this library standalone)
  require 'lib/datasift.php';
  // Load the library via Composer
  //require '/path/to/vendor/autoload.php';

  // An object of this type will receive events
  class EventHandler implements DataSift_IStreamConsumerEventHandler
    public function onInteraction($consumer, $interaction, $hash)
      echo $interaction['interaction']['content']."\n";

    // Ignore the other events for the purposes of this example.
    public function onConnect($consumer)                      { }
    public function onDeleted($consumer, $interaction, $hash) { }
    public function onStatus($consumer, $type, $info)         { }
    public function onWarning($consumer, $message)            { }
    public function onError($consumer, $message)              { }
    public function onDisconnect($consumer)                   { }
    public function onStopped($consumer, $reason)             { }
  // Create the user
  $user = new DataSift_User('your username', 'your api_key');
  // Create a definition looking for the word "datasift"
  $def = $user->createDefinition('interaction.content contains "datasift"');
  // Get an HTTP stream consumer for that definition
  $consumer = $def->getConsumer(DataSift_StreamConsumer::TYPE_HTTP, new EventHandler());
  // Consume it - this will not return unless the stream gets disconnected

See the DataSift documentation for full details of the data contained within each interaction. See this page on our developer site for an example interaction:


Please feel free to contribute to this repository using pull requests.

The unit tests should be run with phpunit.

Note that we use git flow to manage development.


The library will use SSL connections by default. While we recommend using SSL you may disable it if required by passing false as the third parameter when creating a user, or by calling $user->enableSSL(false) on the user object.


All code contained in this repository is Copyright 2011-2015 MediaSift Ltd.

This code is released under the BSD license. Please see the LICENSE file for more details.