PHP Класс Factual

This is a refactoring of the Factual Driver by Aaron: https://github.com/Factual/factual-java-driver
Автор: Tyler
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$config OAuthStore object
$configPath geocoder object (unsupported, experimental)
$connectTimeout maximum number of seconds for the network function to execute (0 = no timeout)
$curlTimeout debug flag
$debug array of queries teed up for multi
$factHome
$fetchQueue last table queried
$geocoder array from config.ini file on construct
$lastTable where the config file is found: path + file
$signer string assigned from config

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

Метод Описание
__construct ( $key, $secret ) Constructor. Creates authenticated access to Factual.
boost ( $factualBoost ) : object Improves search results by associating query with selected record
buildQuery ( $tableName, $query ) : string Build query string without running fetch
clear ( $clear ) : object Clear a/n attribute/s from a Factual entity
debug ( ) Turns on debugging for output to stderr
factualAutoload ( $className ) Autoloader for file dependencies Called by spl_autoload_register() to avoid conflicts with autoload() methods from other libs
factualReverseGeocode ( $point, $tableName = "places" ) : the Reverse geocodes by returning a response containing the address nearest a given point.
fetch ( $tableName, $query ) : object Factual Fetch Abstraction
fetchRow ( string $tableName, $factualID ) : the Runs a read query against the specified Factual table.
flag ( $flagger ) : object Flags entties as problematic
geocode ( $address ) : array Geocodes address string or placename
geocoderDiagnostics ( )
match ( $tableName, $vars ) : object Matches entity to Factual ID (shortcut method)
multiFetch ( ) : response Use this to send all queued reads as a multi request
multiQueue ( $table, $query, $handle ) Queue a request for inclusion in a multi request.
rawGet ( $path, $params ) : string Runs a GET request against the specified endpoint path, using the given parameters and your OAuth credentials. Returns the raw response body returned by Factual. The necessary URL base will be automatically prepended to path. If you need to change it, e.g. to make requests against a development instance of the Factual service, use Factual::setFactHome().
rawPost ( $path, $body, $params = null ) : string Runs a GET request against the specified endpoint path, using the given parameters and your OAuth credentials. Returns the raw response body returned by Factual. The necessary URL base will be automatically prepended to path. If you need to change it, e.g. to make requests against a development instance of the Factual service, use Factual::setFactHome().
resolve ( $tableName, $vars ) : object Resolves and returns resolved entity or null (shortcut method)
reverseGeocode ( $lon, $lat ) : array Reverse geocodes long/lat to the smallest bounding WOEID
schema ( $tableName ) : object
setConnectTimeout ( $secs ) Sets maximum number of seconds to connect to the server before bailing
setCurlTimeout ( $secs ) Sets maximum number of seconds to the network function to execute
setFactHome ( $urlBase ) : void Change the base URL at which to contact Factual's API. This may be useful if you want to talk to a test or staging server withou changing config Example value: http://staging.api.v3.factual.com/t/
submit ( $submittor ) : object Submit data to Factual
version ( ) : string Gets driver version

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

Метод Описание
getGeocoder ( ) : array Geocodes address string or placename
loadConfig ( ) : void Loads config file from ini
request ( string $urlStr, string $requestMethod = "GET", null $params = null, array $curlOptions = [] ) : array Sign the request, perform a curl request and return the results
setConfigPath ( $path ) : void Sets location of config file at runtime
toQueryString ( $parameters ) : string Converts and encodes parameter array to a query string
urlForBoost ( $tableName )
urlForClear ( $tableName, $factualID )
urlForDiffs ( $tableName, $query )
urlForFacets ( $tableName, $query )
urlForFetch ( $tableName, $query )
urlForFetchRow ( $tableName, $factualID )
urlForFlag ( $tableName, $factualID )
urlForGeocode ( $tableName, $query )
urlForMatch ( $tableName, $query )
urlForMulti ( )
urlForResolve ( $tableName, $query )
urlForSchema ( $tableName )
urlForSubmit ( $tableName, $factualID = null )

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

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

Constructor. Creates authenticated access to Factual.
public __construct ( $key, $secret )

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

Improves search results by associating query with selected record
public boost ( $factualBoost ) : object
Результат object

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

Build query string without running fetch
public buildQuery ( $tableName, $query ) : string
Результат string

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

Clear a/n attribute/s from a Factual entity
public clear ( $clear ) : object
Результат object Submit Response object

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

Turns on debugging for output to stderr
public debug ( )

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

Autoloader for file dependencies Called by spl_autoload_register() to avoid conflicts with autoload() methods from other libs
public static factualAutoload ( $className )

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

Reverse geocodes by returning a response containing the address nearest a given point.
public factualReverseGeocode ( $point, $tableName = "places" ) : the
Результат the response of running a reverse geocode query for point against Factual.

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

Factual Fetch Abstraction
public fetch ( $tableName, $query ) : object
Результат object ReadResponse object with result of running query against Factual.

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

Runs a read query against the specified Factual table.
public fetchRow ( string $tableName, $factualID ) : the
$tableName string the name of the table you wish to query (e.g., "places")
Результат the response of running query against Factual.

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

Flags entties as problematic
public flag ( $flagger ) : object
Результат object Flag Response object

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

Geocodes address string or placename
public geocode ( $address ) : array
Результат array

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

public geocoderDiagnostics ( )

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

Geocodes address string or placename
protected getGeocoder ( ) : array
Результат array

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

Loads config file from ini
protected loadConfig ( ) : void
Результат void

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

Matches entity to Factual ID (shortcut method)
public match ( $tableName, $vars ) : object
Результат object MatchResponse

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

Use this to send all queued reads as a multi request
public multiFetch ( ) : response
Результат response for a multi request

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

Queue a request for inclusion in a multi request.
public multiQueue ( $table, $query, $handle )

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

Runs a GET request against the specified endpoint path, using the given parameters and your OAuth credentials. Returns the raw response body returned by Factual. The necessary URL base will be automatically prepended to path. If you need to change it, e.g. to make requests against a development instance of the Factual service, use Factual::setFactHome().
public rawGet ( $path, $params ) : string
Результат string JSON response body from the Factual API.

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

Runs a GET request against the specified endpoint path, using the given parameters and your OAuth credentials. Returns the raw response body returned by Factual. The necessary URL base will be automatically prepended to path. If you need to change it, e.g. to make requests against a development instance of the Factual service, use Factual::setFactHome().
public rawPost ( $path, $body, $params = null ) : string
Результат string JSON response body from the Factual API.

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

Sign the request, perform a curl request and return the results
protected request ( string $urlStr, string $requestMethod = "GET", null $params = null, array $curlOptions = [] ) : array
$urlStr string unsigned URL request
$requestMethod string
$params null
$curlOptions array
Результат array ex: array ('code'=>int, 'headers'=>array(), 'body'=>string)

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

Resolves and returns resolved entity or null (shortcut method)
public resolve ( $tableName, $vars ) : object
Результат object ResolveResponse

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

Reverse geocodes long/lat to the smallest bounding WOEID
public reverseGeocode ( $lon, $lat ) : array
Результат array single result

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

public schema ( $tableName ) : object
Результат object SchemaResponse object

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

Sets location of config file at runtime
protected setConfigPath ( $path ) : void
Результат void

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

Sets maximum number of seconds to connect to the server before bailing
public setConnectTimeout ( $secs )

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

Sets maximum number of seconds to the network function to execute
public setCurlTimeout ( $secs )

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

Change the base URL at which to contact Factual's API. This may be useful if you want to talk to a test or staging server withou changing config Example value: http://staging.api.v3.factual.com/t/
public setFactHome ( $urlBase ) : void
Результат void

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

Submit data to Factual
public submit ( $submittor ) : object
Результат object Submit Response object

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

Converts and encodes parameter array to a query string
protected toQueryString ( $parameters ) : string
Результат string

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

protected urlForBoost ( $tableName )

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

protected urlForClear ( $tableName, $factualID )

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

protected urlForDiffs ( $tableName, $query )

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

protected urlForFacets ( $tableName, $query )

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

protected urlForFetch ( $tableName, $query )

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

protected urlForFetchRow ( $tableName, $factualID )

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

protected urlForFlag ( $tableName, $factualID )

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

protected urlForGeocode ( $tableName, $query )

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

protected urlForMatch ( $tableName, $query )

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

protected urlForMulti ( )

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

protected urlForResolve ( $tableName, $query )

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

protected urlForSchema ( $tableName )

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

protected urlForSubmit ( $tableName, $factualID = null )

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

Gets driver version
public version ( ) : string
Результат string

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

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

OAuthStore object
protected $config

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

geocoder object (unsupported, experimental)
protected $configPath

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

maximum number of seconds for the network function to execute (0 = no timeout)
protected $connectTimeout

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

debug flag
protected $curlTimeout

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

array of queries teed up for multi
protected $debug

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

protected $factHome

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

last table queried
protected $fetchQueue

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

array from config.ini file on construct
protected $geocoder

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

where the config file is found: path + file
protected $lastTable

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

string assigned from config
protected $signer