This software is the intellectual property of MediaSift Ltd., and is covered by retained intellectual property rights, including copyright. Distribution of this software is strictly forbidden under the terms of this license. The DataSift_Pylon class represents a private source
Author: Paul Mozo (paul.mozo@datasift.com)
// Include the DataSift library
require dirname(__FILE__) . '/../../lib/datasift.php';
// Include the configuration - put your username and API key in this file
require dirname(__FILE__) . '/../../config.php';
if (function_exists('date_default_timezone_set')) {
    date_default_timezone_set('UTC');
}
// Authenticate
echo "Creating user...\n";
$user = new DataSift_User(USERNAME, API_KEY, false);
//Set your Analysis Query values
$hash = '<YOUR_RECORDING_HASH>';
// This must be the hash of an active recording
// This filter will likely get redacted; change to something related to your recording, or exclude
$filter = 'fb.content contains "some content"';
$start = mktime(0, 0, 0, date('n'), date('j') - 7);
// 7 days ago
$end = mktime(0, 0, 0, date('n'), date('j'));
// This morning
// Get the PYLON recording by hash
$pylon = DataSift_Pylon::fromHash($user, $hash);
//Set your Analysis Query parameters
$parameters = array('analysis_type' => 'timeSeries', 'parameters' => array('interval' => 'day', 'offset' => -5));
try {
    //Analyze the recording
    $analyze = $pylon->analyze($parameters, false, $start, $end, false);
} catch (Exception $e) {
    echo "Caught exception during analysis:\n";
    print_r($e);
}
echo json_encode($analyze, true);
Example #2
0
 public function testSampleNoId()
 {
     $pylon = new DataSift_Pylon($this->user, array('id' => ''));
     $this->setExpectedException('DataSift_Exception_InvalidData');
     $filter = '(fb.content any "coffee" OR fb.hashtags in "tea") AND fb.language in "en"';
     $start = 1445209200;
     $end = 1445274000;
     $count = 10;
     $pylon->sample($filter, $start, $end, $count);
 }
Example #3
0
 * @link      http://www.mediasift.com
 */
// Include the DataSift library
require dirname(__FILE__) . '/../../lib/datasift.php';
// Include the configuration - put your username and API key in this file
require dirname(__FILE__) . '/../../config.php';
// Authenticate
echo "Creating user...\n";
$user = new DataSift_User(USERNAME, API_KEY, false);
$csdl = '(fb.content any "coffee, tea" OR fb.hashtags in "tea") AND fb.language in "en"';
//Validate the CSDL
$validate = DataSift_Pylon::validate($user, $csdl);
echo "Definition has been successfully validated, DPUs: {$validate['dpu']} created at: {$validate['created_at']} \n\n";
//Create the PYLON object
$pylon_name = "My pylon test";
$pylon = new DataSift_Pylon($user);
$pylon->setName($pylon_name);
//Add CSDL to the PYLON
$pylon->setCsdl($csdl);
$pylon->compile();
//Start the pylon
$pylon->start();
//Stop after 10 seconds
sleep(10);
//Compile some new CSDL
$pylon->setCsdl('(fb.content any "coffee, tea, flour" OR fb.hashtags in "tea") AND fb.language in "en"');
$pylon->compile();
//Update the recording with the new definition
$pylon->update();
$pylon->stop();
//Set the analyze parameters
Example #4
0
/**
 * This simple example demonstrates how to use the Pylon Sample API endpoint
 *
 * @category  DataSift
 * @package   PHP-client
 * @author    Ryan Stanley <*****@*****.**>
 * @copyright 2015 MediaSift Ltd.
 * @license   http://www.debian.org/misc/bsd.license BSD License (3 Clause)
 * @link      http://www.mediasift.com
 */
// Include the DataSift library
require dirname(__FILE__) . '/../../lib/datasift.php';
// Include the configuration - put your username and API key in this file
require dirname(__FILE__) . '/../../config.php';
// Authenticate
echo "Creating user...\n";
$user = new DataSift_User(USERNAME, API_KEY, false);
$filter = '(fb.content any "coffee" OR fb.hashtags in "tea") AND fb.language in "en"';
//Validate the CSDL
$validate = DataSift_Pylon::validate($user, $filter);
echo "Definition has been successfully validated, DPUs: {$validate['dpu']} created at: {$validate['created_at']} \n\n";
//Create the PYLON object and manually enter a Pylon Hash to use in the sample; you'll need to
// replace the hash below with a real PYLON hash from your own DataSift account
$pylon = new DataSift_Pylon($user, array('hash' => '1a4268c9b924d2c48ed1946d6a7e6288'));
// Setting up parameters for the /pylon/sample request
$start = 1445209200;
$end = 1445274000;
$count = 10;
$sample = $pylon->sample($filter, $start, $end, $count);
echo "Sample created successfully";