displaySubscriptionDetails() public method

Displays details of a Historics query.
public displaySubscriptionDetails ( DataSift_Push_Subscription $sub )
$sub DataSift_Push_Subscription A DataSift Push Subscription object
    $push_definition = $env->user->createPushDefinition();
    $push_definition->setOutputType($output_type);
    // Now add the output_type-specific args from the command line
    for ($i = 7; $i < count($env->args); $i++) {
        $bits = explode('=', $env->args[$i], 2);
        if (count($bits) != 2) {
            usage('Invalid output_param: ' . $env->args[$i]);
        }
        $push_definition->setOutputParam($bits[0], $bits[1]);
    }
    // Subscribe the push definition to the historic query
    $push_sub = $push_definition->subscribeHistoric($historic, $name);
    // Start the historic
    $historic->start();
    // Display the details of the new subscription
    $env->displaySubscriptionDetails($push_sub);
} catch (Exception $e) {
    echo 'ERR: ' . get_class($e) . ' ' . $e->getMessage() . PHP_EOL;
}
/**
 * Date string parser.
 *
 * @param string $date Date string.
 */
function parseDate($date)
{
    if (strlen($date) != 14) {
        usage('Invalid date: "' . $date . '"');
    }
    // Expand the date so strtotime can deal with it
    return strtotime(substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6, 2) . ' ' . substr($date, 8, 2) . ':' . substr($date, 10, 2) . ':' . substr($date, 12, 2));
Ejemplo n.º 2
0
 * @copyright 2011 MediaSift Ltd.
 * @license   http://www.debian.org/misc/bsd.license BSD License (3 Clause)
 * @link      http://www.mediasift.com
 */
/**
 * This script displays the details of push subscriptions in your account.
 *
 * NB: Most of the error handling (exception catching) has been removed for
 * the sake of simplicity. Nearly everything in this library may throw
 * exceptions, and production code should catch them. See the documentation
 * for full details.
 */
// Include the shared convenience class
require dirname(__FILE__) . '/env.php';
// Create the env object. This reads the command line arguments, creates the
// user object, and provides access to both along with helper functions
$env = new Env();
// Make sure we have at least one subscription ID
if (count($env->args) == 0) {
    die('Please specify at least one subscription ID!' . PHP_EOL);
}
// Cycle through the IDs passed on the command line
foreach ($env->args as $sub_id) {
    try {
        $sub = $env->user->getPushSubscription($sub_id);
        $env->displaySubscriptionDetails($sub);
    } catch (Exception $e) {
        echo get_class($e) . ' ' . $e->getMessage() . PHP_EOL;
    }
    echo '--' . PHP_EOL;
}