PHP Class DataSift_User

Author: Stuart Dallas ([email protected])
显示文件 Open project: datasift/datasift-php Class Usage Examples

Protected Properties

Property Type Description
$_api_client The class to use as the API client.
$_api_key The DataSift API Key.
$_api_url The api url of the user.
$_api_version
$_debug Boolean to represent whether this class is being used in debug mode or not
$_ingest_url The ingestion url of the user.
$_last_response The full response of the last API call, only set in debug mode.
$_rate_limit Stores the X-RateLimit-Limit value from the last API call.
$_rate_limit_remaining Stores the X-RateLimit-Remaining value from the last API call.
$_stream_url The apu url of the user.
$_use_ssl Set to true to enable SSL.
$_username The DataSift username.

Public Methods

Method Description
__construct ( string $username, string $api_key, boolean $use_ssl = true, $debug_mode = false, $api_url = false, $api_version = false, $stream_url = false, $ingest_url = false ) Constructor. A username and API key are required when constructing an instance of this class.
createDefinition ( string $definition = '' ) : DataSift_Definition Creates and returns an empty Definition object.
createHistoric ( string $hash, integer $start, integer $end, array $sources, string $name, float $sample = DataSift_Historic::DEFAULT_SAMPLE ) : DataSift_Historic Create a historic query based on a stream hash.
createPushDefinition ( ) : DataSift_Push_Definition Creates and returns a new Push_Definition object.
delete ( string $endpoint, array $params = [], $headers = [] ) : array Make a Delete call to a DataSift API endpoint.
enableSSL ( boolean $use_ssl = true ) : void Set whether stream connections should use SSL.
get ( string $endpoint, array $params = [], $headers = [] ) : array Make a GET call to a DataSift API endpoint.
getAPIKey ( ) : string Returns the API key.
getApiUrl ( ) : string Returns API URL.
getApiVersion ( ) : string getApiVersion
getConsumer ( string $type = DataSift_StreamConsumer::TYPE_HTTP, string $hash, DataSift_IStreamConsumerEventHandler $eventHandler ) : DataSift_StreamConsumer Returns a DataSift_StreamConsumer-derived object for the given hash, for the given type.
getDebug ( ) : boolean getDebug
getHistoric ( string $playback_id ) : DataSift_Historic Get an existing historic from the API.
getIngestUrl ( ) : string Returns stream URL.
getLastResponse ( ) : array getLastResponse
getMultiConsumer ( string $type = DataSift_StreamConsumer::TYPE_HTTP, string $hashes, DataSift_IStreamConsumerEventHandler $eventHandler ) : DataSift_StreamConsumer Returns a DataSift_StreamConsumer-derived object for the given hashes, for the given type.
getPushSubscription ( string $id ) : DataSift_Push_Subscription Get a single push subscription.
getPushSubscriptionLogs ( $page = 1, $per_page = 100, $order_by = DataSift_Push_Subscription::ORDERBY_REQUEST_TIME, $order_dir = DataSift_Push_Subscription::ORDERDIR_DESC ) : ArrayList Page through recent push subscription log entries, specifying the sort order.
getRateLimit ( ) : integer Returns the rate limit returned by the last API call.
getRateLimitRemaining ( ) : integer Returns the rate limit remaining returned by the last API call.
getStreamUrl ( ) : string Returns stream URL.
getUsage ( string $period = 'hour' ) : array Returns the usage data for this user.
getUserAgent ( ) : string Returns the user agent this library should use for all API calls.
getUsername ( ) : string Returns the username.
listHistorics ( integer $page = 1, integer $per_page = 20 ) : array Get a list of Historics queries in your account.
listPushSubscriptions ( integer $page = 1, integer $per_page = 100, $order_by = DataSift_Push_Subscription::ORDERBY_CREATED_AT, $order_dir = DataSift_Push_Subscription::ORDERDIR_ASC, boolean $include_finished = false ) : array Get a list of push subscriptions in your account.
post ( string $endpoint, array $params = [], $headers = [], $ingest = false ) : array Make a call to a DataSift API endpoint.
put ( string $endpoint, array $params = [], $headers = [] ) : array Make a PUT call to a DataSift API endpoint.
setApiClient ( string $api_client ) : void Set the class to use when calling the API
setApiVersion ( string $version ) : string setApiVersion
setLastResponse ( array $last_response ) setLastResponse
useSSL ( ) : boolean Returns whether SSL should be used where supported.

Private Methods

Method Description
handleResponse ( $res )

Method Details

__construct() public method

Constructor. A username and API key are required when constructing an instance of this class.
public __construct ( string $username, string $api_key, boolean $use_ssl = true, $debug_mode = false, $api_url = false, $api_version = false, $stream_url = false, $ingest_url = false )
$username string The user's username.
$api_key string The user's API key.
$use_ssl boolean Set to true to enable SSL.

createDefinition() public method

Creates and returns an empty Definition object.
public createDefinition ( string $definition = '' ) : DataSift_Definition
$definition string Optional definition with which to prime the object.
return DataSift_Definition A definition object tied to this user.

createHistoric() public method

Create a historic query based on a stream hash.
public createHistoric ( string $hash, integer $start, integer $end, array $sources, string $name, float $sample = DataSift_Historic::DEFAULT_SAMPLE ) : DataSift_Historic
$hash string The stream hash.
$start integer The timestamp from which to start the query.
$end integer The timestamp at which to end the query.
$sources array An array of sources required.
$name string A friendly name for this query.
$sample float An optional sample rate for this query.
return DataSift_Historic

createPushDefinition() public method

Creates and returns a new Push_Definition object.
public createPushDefinition ( ) : DataSift_Push_Definition
return DataSift_Push_Definition

delete() public method

Make a Delete call to a DataSift API endpoint.
public delete ( string $endpoint, array $params = [], $headers = [] ) : array
$endpoint string The endpoint of the API call.
$params array The parameters to be passed along with the request.
return array The response from the server.

enableSSL() public method

Set whether stream connections should use SSL.
public enableSSL ( boolean $use_ssl = true ) : void
$use_ssl boolean Set to true to enable SSL.
return void

get() public method

Make a GET call to a DataSift API endpoint.
public get ( string $endpoint, array $params = [], $headers = [] ) : array
$endpoint string The endpoint of the API call.
$params array The parameters to be passed along with the request.
return array The response from the server.

getAPIKey() public method

Returns the API key.
public getAPIKey ( ) : string
return string The API key.

getApiUrl() public method

Returns API URL.
public getApiUrl ( ) : string
return string

getApiVersion() public method

getApiVersion
public getApiVersion ( ) : string
return string

getConsumer() public method

Returns a DataSift_StreamConsumer-derived object for the given hash, for the given type.
See also: DataSift_StreamConsumer
public getConsumer ( string $type = DataSift_StreamConsumer::TYPE_HTTP, string $hash, DataSift_IStreamConsumerEventHandler $eventHandler ) : DataSift_StreamConsumer
$type string The consumer type for which to construct a consumer.
$hash string The hash to be consumed.
$eventHandler DataSift_IStreamConsumerEventHandler The object that will receive events.
return DataSift_StreamConsumer The consumer object.

getDebug() public method

getDebug
public getDebug ( ) : boolean
return boolean

getHistoric() public method

Get an existing historic from the API.
public getHistoric ( string $playback_id ) : DataSift_Historic
$playback_id string The historic playback ID.
return DataSift_Historic

getIngestUrl() public method

Returns stream URL.
public getIngestUrl ( ) : string
return string

getLastResponse() public method

getLastResponse
public getLastResponse ( ) : array
return array

getMultiConsumer() public method

Returns a DataSift_StreamConsumer-derived object for the given hashes, for the given type.
See also: DataSift_StreamConsumer
public getMultiConsumer ( string $type = DataSift_StreamConsumer::TYPE_HTTP, string $hashes, DataSift_IStreamConsumerEventHandler $eventHandler ) : DataSift_StreamConsumer
$type string The consumer type for which to construct a consumer.
$hashes string An array containing hashes and/or Definition objects to be consumed.
$eventHandler DataSift_IStreamConsumerEventHandler The object that will receive events.
return DataSift_StreamConsumer The consumer object.

getPushSubscription() public method

Get a single push subscription.
public getPushSubscription ( string $id ) : DataSift_Push_Subscription
$id string The ID of the subscription to fetch.
return DataSift_Push_Subscription

getPushSubscriptionLogs() public method

Page through recent push subscription log entries, specifying the sort order.
public getPushSubscriptionLogs ( $page = 1, $per_page = 100, $order_by = DataSift_Push_Subscription::ORDERBY_REQUEST_TIME, $order_dir = DataSift_Push_Subscription::ORDERDIR_DESC ) : ArrayList
return ArrayList

getRateLimit() public method

Returns the rate limit returned by the last API call.
public getRateLimit ( ) : integer
return integer The rate limit.

getRateLimitRemaining() public method

Returns the rate limit remaining returned by the last API call.
public getRateLimitRemaining ( ) : integer
return integer The rate limit remaining.

getStreamUrl() public method

Returns stream URL.
public getStreamUrl ( ) : string
return string

getUsage() public method

Returns the usage data for this user.
public getUsage ( string $period = 'hour' ) : array
$period string Either 'hour' or 'day'.
return array The usage data from the API.

getUserAgent() public method

Returns the user agent this library should use for all API calls.
public getUserAgent ( ) : string
return string

getUsername() public method

Returns the username.
public getUsername ( ) : string
return string The username.

listHistorics() public method

Get a list of Historics queries in your account.
public listHistorics ( integer $page = 1, integer $per_page = 20 ) : array
$page integer The page number to get.
$per_page integer The number of items per page.
return array Of DataSift_Historic objects.

listPushSubscriptions() public method

Get a list of push subscriptions in your account.
public listPushSubscriptions ( integer $page = 1, integer $per_page = 100, $order_by = DataSift_Push_Subscription::ORDERBY_CREATED_AT, $order_dir = DataSift_Push_Subscription::ORDERDIR_ASC, boolean $include_finished = false ) : array
$page integer The page number to get.
$per_page integer The number of items per page.
$include_finished boolean Set to true when you want to include finished subscription in the results.
return array Of DataSift_Push_Subscription objects.

post() public method

Make a call to a DataSift API endpoint.
public post ( string $endpoint, array $params = [], $headers = [], $ingest = false ) : array
$endpoint string The endpoint of the API call.
$params array The parameters to be passed along with the request.
return array The response from the server.

put() public method

Make a PUT call to a DataSift API endpoint.
public put ( string $endpoint, array $params = [], $headers = [] ) : array
$endpoint string The endpoint of the API call.
$params array The parameters to be passed along with the request.
return array The response from the server.

setApiClient() public method

Set the class to use when calling the API
public setApiClient ( string $api_client ) : void
$api_client string The class to use.
return void

setApiVersion() public method

setApiVersion
public setApiVersion ( string $version ) : string
$version string
return string

setLastResponse() public method

setLastResponse
public setLastResponse ( array $last_response )
$last_response array

useSSL() public method

Returns whether SSL should be used where supported.
public useSSL ( ) : boolean
return boolean True if SSL should be used.

Property Details

$_api_client protected_oe property

The class to use as the API client.
protected $_api_client

$_api_key protected_oe property

The DataSift API Key.
protected $_api_key

$_api_url protected_oe property

The api url of the user.
protected $_api_url

$_api_version protected_oe property

protected $_api_version

$_debug protected_oe property

Boolean to represent whether this class is being used in debug mode or not
protected $_debug

$_ingest_url protected_oe property

The ingestion url of the user.
protected $_ingest_url

$_last_response protected_oe property

The full response of the last API call, only set in debug mode.
protected $_last_response

$_rate_limit protected_oe property

Stores the X-RateLimit-Limit value from the last API call.
protected $_rate_limit

$_rate_limit_remaining protected_oe property

Stores the X-RateLimit-Remaining value from the last API call.
protected $_rate_limit_remaining

$_stream_url protected_oe property

The apu url of the user.
protected $_stream_url

$_use_ssl protected_oe property

Set to true to enable SSL.
protected $_use_ssl

$_username protected_oe property

The DataSift username.
protected $_username