PHP Class Factual

This is a refactoring of the Factual Driver by Aaron: https://github.com/Factual/factual-java-driver
Author: Tyler
Afficher le fichier Open project: factual/factual-php-driver Class Usage Examples

Protected Properties

Свойство Type Description
$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

Méthodes publiques

Méthode Description
__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

Méthodes protégées

Méthode Description
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 )

Method Details

__construct() public méthode

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

boost() public méthode

Improves search results by associating query with selected record
public boost ( $factualBoost ) : object
Résultat object

buildQuery() public méthode

Build query string without running fetch
public buildQuery ( $tableName, $query ) : string
Résultat string

clear() public méthode

Clear a/n attribute/s from a Factual entity
public clear ( $clear ) : object
Résultat object Submit Response object

debug() public méthode

Turns on debugging for output to stderr
public debug ( )

factualAutoload() public static méthode

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

factualReverseGeocode() public méthode

Reverse geocodes by returning a response containing the address nearest a given point.
public factualReverseGeocode ( $point, $tableName = "places" ) : the
Résultat the response of running a reverse geocode query for point against Factual.

fetch() public méthode

Factual Fetch Abstraction
public fetch ( $tableName, $query ) : object
Résultat object ReadResponse object with result of running query against Factual.

fetchRow() public méthode

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")
Résultat the response of running query against Factual.

flag() public méthode

Flags entties as problematic
public flag ( $flagger ) : object
Résultat object Flag Response object

geocode() public méthode

Geocodes address string or placename
public geocode ( $address ) : array
Résultat array

geocoderDiagnostics() public méthode

public geocoderDiagnostics ( )

getGeocoder() protected méthode

Geocodes address string or placename
protected getGeocoder ( ) : array
Résultat array

loadConfig() protected méthode

Loads config file from ini
protected loadConfig ( ) : void
Résultat void

match() public méthode

Matches entity to Factual ID (shortcut method)
public match ( $tableName, $vars ) : object
Résultat object MatchResponse

multiFetch() public méthode

Use this to send all queued reads as a multi request
public multiFetch ( ) : response
Résultat response for a multi request

multiQueue() public méthode

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

rawGet() public méthode

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
Résultat string JSON response body from the Factual API.

rawPost() public méthode

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
Résultat string JSON response body from the Factual API.

request() protected méthode

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
Résultat array ex: array ('code'=>int, 'headers'=>array(), 'body'=>string)

resolve() public méthode

Resolves and returns resolved entity or null (shortcut method)
public resolve ( $tableName, $vars ) : object
Résultat object ResolveResponse

reverseGeocode() public méthode

Reverse geocodes long/lat to the smallest bounding WOEID
public reverseGeocode ( $lon, $lat ) : array
Résultat array single result

schema() public méthode

public schema ( $tableName ) : object
Résultat object SchemaResponse object

setConfigPath() protected méthode

Sets location of config file at runtime
protected setConfigPath ( $path ) : void
Résultat void

setConnectTimeout() public méthode

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

setCurlTimeout() public méthode

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

setFactHome() public méthode

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
Résultat void

submit() public méthode

Submit data to Factual
public submit ( $submittor ) : object
Résultat object Submit Response object

toQueryString() protected méthode

Converts and encodes parameter array to a query string
protected toQueryString ( $parameters ) : string
Résultat string

urlForBoost() protected méthode

protected urlForBoost ( $tableName )

urlForClear() protected méthode

protected urlForClear ( $tableName, $factualID )

urlForDiffs() protected méthode

protected urlForDiffs ( $tableName, $query )

urlForFacets() protected méthode

protected urlForFacets ( $tableName, $query )

urlForFetch() protected méthode

protected urlForFetch ( $tableName, $query )

urlForFetchRow() protected méthode

protected urlForFetchRow ( $tableName, $factualID )

urlForFlag() protected méthode

protected urlForFlag ( $tableName, $factualID )

urlForGeocode() protected méthode

protected urlForGeocode ( $tableName, $query )

urlForMatch() protected méthode

protected urlForMatch ( $tableName, $query )

urlForMulti() protected méthode

protected urlForMulti ( )

urlForResolve() protected méthode

protected urlForResolve ( $tableName, $query )

urlForSchema() protected méthode

protected urlForSchema ( $tableName )

urlForSubmit() protected méthode

protected urlForSubmit ( $tableName, $factualID = null )

version() public méthode

Gets driver version
public version ( ) : string
Résultat string

Property Details

$config protected_oe property

OAuthStore object
protected $config

$configPath protected_oe property

geocoder object (unsupported, experimental)
protected $configPath

$connectTimeout protected_oe property

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

$curlTimeout protected_oe property

debug flag
protected $curlTimeout

$debug protected_oe property

array of queries teed up for multi
protected $debug

$factHome protected_oe property

protected $factHome

$fetchQueue protected_oe property

last table queried
protected $fetchQueue

$geocoder protected_oe property

array from config.ini file on construct
protected $geocoder

$lastTable protected_oe property

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

$signer protected_oe property

string assigned from config
protected $signer