PHP Класс Swiftriver\Core\Modules\Phirehose

Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$avgPeriod
$buff
$conn
$connectFailuresMax Config type vars - override in subclass if desired
$connectTimeout
$count
$fdrPool
$filterChanged State vars
$followIds
$format
$idleReconnectTimeout
$lastErrorMsg
$lastErrorNo
$locationBoxes
$method
$password
$readTimeout
$reconnect
$statusRate
$trackWords
$username Member Attribs

Открытые методы

Метод Описание
__construct ( string $username, string $password, string $method = Phirehose::METHOD_SAMPLE, string $format = self::FORMAT_JSON ) Create a new Phirehose object attached to the appropriate twitter stream method.
consume ( boolean $reconnect = TRUE ) Connects to the stream API and consumes the stream. Each status update in the stream will cause a call to the handleStatus() method.
enqueueStatus ( string $status ) This is the one and only method that must be implemented additionally. As per the streaming API documentation, statuses should NOT be processed within the same process that is performing collection
getFollow ( ) : array Returns an array of followed Twitter userIds (integers)
getLastErrorMsg ( ) : string Returns the last error message (TCP or HTTP) that occured with the streaming API or client. State is cleared upon successful reconnect
getLastErrorNo ( ) : string Returns the last error number that occured with the streaming API or client. Numbers correspond to either the fsockopen() error states (in the case of TCP errors) or HTTP error codes from Twitter (in the case of HTTP errors).
getLocations ( ) : array Returns an array of 4 element arrays that denote the monitored location bounding boxes for tweets using the Geotagging API.
getTrack ( ) : array Returns an array of keywords being tracked
setCount ( integer $count ) Sets the number of previous statuses to stream before transitioning to the live stream. Applies only to firehose and filter + track methods. This is generally used internally and should not be needed by client applications.
setFollow ( array $userIds ) Returns public statuses from or in reply to a set of users. Mentions ("Hello @user!") and implicit replies ("@user Hello!" created without pressing the reply button) are not matched. It is up to you to find the integer IDs of each twitter user.
setLocations ( array $boundingBoxes ) Specifies a set of bounding boxes to track as an array of 4 element lon/lat pairs denoting , . Only tweets that are both created using the Geotagging API and are placed from within a tracked bounding box will be included in the stream. The user's location field is not used to filter tweets. Bounding boxes are logical ORs and must be less than or equal to 1 degree per side. A locations parameter may be combined with track parameters, but note that all terms are logically ORd.
setLocationsByCircle ( $locations ) Convenience method that sets location bounding boxes by an array of lon/lat/radius sets, rather than manually specified bounding boxes. Each array element should contain 3 element subarray containing a latitude, longitude and radius. Radius is specified in kilometers and is approximate (as boxes are square).
setTrack ( array $trackWords ) Specifies keywords to track. Track keywords are case-insensitive logical ORs. Terms are exact-matched, ignoring punctuation. Phrases, keywords with spaces, are not supported. Queries are subject to Track Limitations.

Защищенные методы

Метод Описание
checkFilterPredicates ( ) Method called as frequently as practical (every 5+ seconds) that is responsible for checking if filter predicates (ie: track words or follow IDs) have changed. If they have, they should be set using the setTrack() and setFollow() methods respectively within the overridden implementation.
connect ( ) Connects to the stream URL using the configured method.
disconnect ( ) Performs forcible disconnect from stream (if connected) and cleanup.
log ( $message ) Basic log function that outputs logging to the standard error_log() handler. This should generally be overridden to suit the application environment.

Приватные методы

Метод Описание
reconnect ( ) Reconnects as quickly as possible. Should be called whenever a reconnect is required rather that connect/disconnect to preserve streams reconnect state

Описание методов

__construct() публичный Метод

Methods are: METHOD_FIREHOSE, METHOD_RETWEET, METHOD_SAMPLE, METHOD_FILTER Formats are: FORMAT_JSON, FORMAT_XML
См. также: Phirehose::METHOD_SAMPLE
См. также: Phirehose::FORMAT_JSON
public __construct ( string $username, string $password, string $method = Phirehose::METHOD_SAMPLE, string $format = self::FORMAT_JSON )
$username string Any twitter username
$password string Any twitter password
$method string
$format string

checkFilterPredicates() защищенный Метод

Note that even if predicates are changed every 5 seconds, an actual reconnect will not happen more frequently than every 2 minutes (as per Twitter Streaming API documentation). Note also that this method is called upon every connect attempt, so if your predicates are causing connection errors, they should be checked here and corrected. This should be implemented/overridden in any subclass implementing the FILTER method.
См. также: setTrack()
См. также: setFollow()
См. также: Phirehose::METHOD_FILTER
protected checkFilterPredicates ( )

connect() защищенный Метод

Connects to the stream URL using the configured method.
protected connect ( )

consume() публичный Метод

Connects to the stream API and consumes the stream. Each status update in the stream will cause a call to the handleStatus() method.
См. также: handleStatus()
public consume ( boolean $reconnect = TRUE )
$reconnect boolean Reconnects as per recommended

disconnect() защищенный Метод

Performs forcible disconnect from stream (if connected) and cleanup.
protected disconnect ( )

enqueueStatus() абстрактный публичный Метод

This is the one and only method that must be implemented additionally. As per the streaming API documentation, statuses should NOT be processed within the same process that is performing collection
abstract public enqueueStatus ( string $status )
$status string

getFollow() публичный Метод

Returns an array of followed Twitter userIds (integers)
public getFollow ( ) : array
Результат array

getLastErrorMsg() публичный Метод

Returns the last error message (TCP or HTTP) that occured with the streaming API or client. State is cleared upon successful reconnect
public getLastErrorMsg ( ) : string
Результат string

getLastErrorNo() публичный Метод

State is cleared upon successful reconnect.
public getLastErrorNo ( ) : string
Результат string

getLocations() публичный Метод

Returns an array of 4 element arrays that denote the monitored location bounding boxes for tweets using the Geotagging API.
См. также: setLocations()
public getLocations ( ) : array
Результат array

getTrack() публичный Метод

Returns an array of keywords being tracked
public getTrack ( ) : array
Результат array

log() защищенный Метод

Basic log function that outputs logging to the standard error_log() handler. This should generally be overridden to suit the application environment.
См. также: error_log()
protected log ( $message )

setCount() публичный Метод

Applies to: METHOD_FILTER, METHOD_FIREHOSE
public setCount ( integer $count )
$count integer

setFollow() публичный Метод

Applies to: METHOD_FILTER
public setFollow ( array $userIds )
$userIds array Array of Twitter integer userIDs

setLocations() публичный Метод

NOTE: The argument order is Longitude/Latitude (to match the Twitter API and GeoJSON specifications). Applies to: METHOD_FILTER See: http://apiwiki.twitter.com/Streaming-API-Documentation#locations Eg: setLocations(array( array(-122.75, 36.8, -121.75, 37.8), // San Francisco array(-74, 40, -73, 41), // New York ));
public setLocations ( array $boundingBoxes )
$boundingBoxes array

setLocationsByCircle() публичный Метод

NOTE: The argument order is Longitude/Latitude (to match the Twitter API and GeoJSON specifications). Eg: setLocationsByCircle(array( array(144.9631, -37.8142, 30), // Melbourne, 3km radius array(-0.1262, 51.5001, 25), // London 10km radius ));
См. также: setLocations()
public setLocationsByCircle ( $locations )

setTrack() публичный Метод

Applies to: METHOD_FILTER See: http://apiwiki.twitter.com/Streaming-API-Documentation#TrackLimiting
public setTrack ( array $trackWords )
$trackWords array

Описание свойств

$avgPeriod защищенное свойство

protected $avgPeriod

$buff защищенное свойство

protected $buff

$conn защищенное свойство

protected $conn

$connectFailuresMax защищенное свойство

Config type vars - override in subclass if desired
protected $connectFailuresMax

$connectTimeout защищенное свойство

protected $connectTimeout

$count защищенное свойство

protected $count

$fdrPool защищенное свойство

protected $fdrPool

$filterChanged защищенное свойство

State vars
protected $filterChanged

$followIds защищенное свойство

protected $followIds

$format защищенное свойство

protected $format

$idleReconnectTimeout защищенное свойство

protected $idleReconnectTimeout

$lastErrorMsg защищенное свойство

protected $lastErrorMsg

$lastErrorNo защищенное свойство

protected $lastErrorNo

$locationBoxes защищенное свойство

protected $locationBoxes

$method защищенное свойство

protected $method

$password защищенное свойство

protected $password

$readTimeout защищенное свойство

protected $readTimeout

$reconnect защищенное свойство

protected $reconnect

$statusRate защищенное свойство

protected $statusRate

$trackWords защищенное свойство

protected $trackWords

$username защищенное свойство

Member Attribs
protected $username