Get a page of push subscriptions in the given user's account, where
each page contains up to per_page items. Results will be ordered
according to the supplied ordering parameters.
public static listSubscriptions ( DataSift_User $user, integer $page = 1, integer $per_page = 20, string $order_by = self::ORDERBY_CREATED_AT, string $order_dir = self::ORDERDIR_ASC, boolean $include_finished = false, string $hash_type = false, string $hash = false ) : array | ||
$user | DataSift_User | The user. |
$page | integer | The page number to fetch. |
$per_page | integer | The number of items per page. |
$order_by | string | The field on which to order the results. |
$order_dir | string | The direction of the ordering. |
$include_finished | boolean | True to include subscriptions against finished historic queries. |
$hash_type | string | Stream hash or Historics playback id. |
$hash | string | The stream hash or historics subscription id string. |
Résultat | array | Of DataSift_Push_Subscription objects. |
/** * Get a list of push subscriptions in your account. * * @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. * * @return array Of DataSift_Push_Subscription objects. * @throws DataSift_Exception_InvalidData * @throws DataSift_Exception_APIError * @throws DataSift_Exception_AccessDenied */ public function listPushSubscriptions($page = 1, $per_page = 100, $order_by = DataSift_Push_Subscription::ORDERBY_CREATED_AT, $order_dir = DataSift_Push_Subscription::ORDERDIR_ASC, $include_finished = false) { return DataSift_Push_Subscription::listSubscriptions($this, $page, $per_page, $order_by, $order_dir, $include_finished); }
/** * 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); }
<?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"; }