Author: Stuart Dallas (stuart@3ft9.com)
Inheritance: extends DataSift_Push_Definition
Exemple #1
0
 /**
  * Displays details of a Historics query.
  *
  * @param DataSift_Push_Subscription $sub A DataSift Push Subscription object
  */
 public function displaySubscriptionDetails($sub)
 {
     echo 'ID:            ' . $sub->getId() . PHP_EOL;
     echo 'Name:          ' . $sub->getName() . PHP_EOL;
     echo 'Status:        ' . $sub->getStatus() . PHP_EOL;
     echo 'Created at:    ' . (is_null($sub->getCreatedAt()) ? 'null' : date('r', $sub->getCreatedAt())) . PHP_EOL;
     echo 'Last request:  ' . (is_null($sub->getLastRequest()) ? 'null' : date('r', $sub->getLastRequest())) . PHP_EOL;
     echo 'Last success:  ' . (is_null($sub->getLastSuccess()) ? 'null' : date('r', $sub->getLastSuccess())) . PHP_EOL;
     echo 'Output Type:   ' . $sub->getOutputType() . PHP_EOL;
     echo 'Output Params:' . PHP_EOL;
     foreach ($sub->getOutputParams() as $key => $val) {
         echo '  ' . $key . ' = ' . $val . PHP_EOL;
     }
 }
Exemple #2
0
 /**
  * Page through recent push subscription log entries, specifying the sort
  * order.
  *
  * @param int    page      Which page to fetch.
  * @param int    per_page  Based on this page size.
  * @param String order_by  Which field to sort by.
  * @param String order_dir In asc[ending] or desc[ending] order.
  * @return ArrayList<LogEntry>
  * @throws DataSift_Exception_AccessDenied
  * @throws DataSift_Exception_InvalidData
  * @throws DataSift_Exception_APIError
  */
 public function getPushSubscriptionLogs($page = 1, $per_page = 100, $order_by = DataSift_Push_Subscription::ORDERBY_REQUEST_TIME, $order_dir = DataSift_Push_Subscription::ORDERDIR_DESC)
 {
     return DataSift_Push_Subscription::getLogs($this, $page, $per_page, $order_by, $order_dir);
 }
Exemple #3
0
 /**
  * Get a page of push subscriptions for this historic query, where each
  * page contains up to $per_page items. Results will be returned in the
  * order requested.
  *
  * @param DataSift_User $user The user object.
  * @param int $page The page number to get.
  * @param int $per_page The number of items per page.
  * @param String $order_by  Which field to sort by.
  * @param String $order_dir In asc[ending] or desc[ending] order.
  * @param bool $include_finished Set to true when you want to include finished subscription in the results.
  */
 public function getPushSubscriptions($user, $page = 1, $per_page = 20, $order_by = self::ORDERBY_CREATED_AT, $order_dir = self::ORDERDIR_ASC, $include_finished = false)
 {
     if ($this->_deleted) {
         throw new DataSift_Exception_InvalidData('Cannot get the push subscriptions for a deleted Historic.');
     }
     if ($this->_playback_id === false || strlen($this->_playback_id) == 0) {
         throw new DataSift_Exception_InvalidData('Cannot get the push subscriptions for a historic query that hasn\'t been prepared.');
     }
     return DataSift_Push_Subscription::listSubscriptions($this->_user, $page, $per_page, $order_by, $order_dir, $include_finished, $hash_type = 'playback_id', $this->_playback_id);
 }
Exemple #4
0
<?php

/**
 * DataSift client
 *
 * This software is the intellectual property of MediaSift Ltd., and is covered
 * by retained intellectual property rights, including copyright.
 *
 * @category  DataSift
 * @package   PHP-client
 * @author    Paul Mozo <*****@*****.**>
 * @copyright 2011 MediaSift Ltd.
 * @license   http://www.debian.org/misc/bsd.license BSD License (3 Clause)
 * @link      http://www.mediasift.com
 */
/**
 * This script loads all active subscriptions, reloads them and outputs their status.
 *
 */
require dirname(__FILE__) . '/../../lib/datasift.php';
require dirname(__FILE__) . '/../../config.php';
$user = new DataSift_User(USERNAME, API_KEY);
$subs = DataSift_Push_Subscription::listSubscriptions($user);
if ($subs['count'] > 0) {
    foreach ($subs['subscriptions'] as $sub) {
        $sub->reload();
        echo $sub->getId() . " Status: " . $sub->getStatus() . "\n";
    }
} else {
    echo "No active subscriptions";
}