PHP Class AdsUser, googleads-php-lib

显示文件 Open project: googleads/googleads-php-lib Class Usage Examples

Public Methods

Method Description
GetClientLibraryUserAgent ( ) : string Gets the user agent string that identifies this library for this user.
GetDefaultOAuth2Handler ( null | string $className = null ) : mixed Get the default OAuth2 Handler for this user.
GetDefaultServer ( ) : string Gets the default server.
GetDefaultVersion ( ) : string Gets the default version.
GetForceAddXsiTypes ( ) : boolean Gets the setting of whether or not to add XSI types in the SOAP payload.
GetForceHttpVersion ( ) : float Gets the version of the HTTP protocol to use regardless of PHP version.
GetHeaderNames ( ) : array Gets the names of all registered request header elements.
GetHeaderValue ( string $key ) : string Gets the value for a registered request header element.
GetLogsDirectory ( ) : string Gets the logs directory.
GetOAuth2Handler ( ) : OAuth2Handler Gets the OAuth2 handler for this user.
GetOAuth2Info ( ) : array Gets the OAuth2 info for this user.
GetServiceSoapClient ( string $serviceName, SoapClientFactory $serviceFactory ) : SoapClient Gets the service by its service name.
GetSoapCompressionLevel ( ) : integer Gets the SOAP compression level.
GetWsdlCacheType ( ) : integer Gets the type of WSDL caching in use.
IsSoapCompressionEnabled ( ) : boolean Is SOAP compression enabled.
LoadSettings ( string $settingsIniPath, string $defaultVersion, string $defaultServer, string $defaultLogsDir, string $logsRelativePathBase ) Loads the settings for this client library. If the settings INI file located at $settingsIniPath cannot be loaded, then the parameters passed into this method are used.
LogAll ( ) Configures the library to log all requests.
LogDefaults ( ) Configures the library to log basic information about all requests and the full SOAP XML request and response only when an error occurs.
LogErrors ( ) Configures the library to only log requests that return an error.
SetDefaultServer ( string $defaultServer ) Sets the default server.
SetDefaultVersion ( string $defaultVersion ) Sets the default version.
SetHeaderValue ( string $key, string $value ) Sets the value for a request header.
SetOAuth2Handler ( array $oauth2Handler ) Sets the OAuth2 handler for this user.
SetOAuth2Info ( array $oauth2Info ) Sets the OAuth2 info for this user.
getIsIncludeUtilitiesInUserAgent ( ) : boolean
setIncludeUtilitiesInUserAgent ( boolean $isIncludeUtilitiesInUserAgent )
updateClientLibraryUserAgent ( string $applicationName ) Sets the user agent string that identifies this library for this user.

Protected Methods

Method Description
GetAuthVarValue ( string | null $authVar, string $authVarName, array $authIni ) : string Gets the authenticaiton value for the $authVar supplied. If the $authVar is set, it is is used. Otherwise, the supplied $authenticationIni is queried for the variable. If none is found null is returned.
GetClientLibraryNameAndVersion ( ) : array Gets the name and version of this client library.
GetUserAgentHeaderName ( ) : string Gets the appropriate user agent header name for the API this client library is targeting.
InitLogs ( ) Initializes the logging mechanism used by services created by this user.
ValidateOAuth2Info ( ) Validates that the OAuth2 info is complete.
__construct ( ) Constructor for AdsUser.

Private Methods

Method Description
Define ( string $name, string $value ) Define a constant if it isn't already defined. If it is defined but the value is different then attempt to redefine it, which will fail and throw the appropriate error.
GetAllClientLibraryUserAgentParts ( ) : array Gets all the user agent parts that identify this client library plus user agent parts from the ads utilities registry.
GetCommonClientLibraryUserAgentParts ( ) : array Gets common PHP user agent parts for ads client libraries such as PHP version, operating system, browser, or if compression is being used or not.
GetSetting ( array $settings, string $section, string $name, mixed $default = null ) : string Gets the value for a given setting based on the contents of the parsed INI file.

Method Details

GetAuthVarValue() protected method

Gets the authenticaiton value for the $authVar supplied. If the $authVar is set, it is is used. Otherwise, the supplied $authenticationIni is queried for the variable. If none is found null is returned.
protected GetAuthVarValue ( string | null $authVar, string $authVarName, array $authIni ) : string
$authVar string | null the default value for the authentication variable
$authVarName string the name of the authentication variable
$authIni array the array of authentication variables from an INI file
return string the authentication variable value

GetClientLibraryNameAndVersion() abstract protected method

Gets the name and version of this client library.
abstract protected GetClientLibraryNameAndVersion ( ) : array
return array An array containing the name and version of this client library, e.g.: ['DfpApi-PHP', '2.13.0'].

GetClientLibraryUserAgent() public method

Gets the user agent string that identifies this library for this user.
public GetClientLibraryUserAgent ( ) : string
return string A user agent string.

GetDefaultOAuth2Handler() abstract public method

Get the default OAuth2 Handler for this user.
abstract public GetDefaultOAuth2Handler ( null | string $className = null ) : mixed
$className null | string the name of the oauth2Handler class or null
return mixed the configured OAuth2Handler class

GetDefaultServer() public method

Gets the default server.
public GetDefaultServer ( ) : string
return string the default server

GetDefaultVersion() public method

Gets the default version.
public GetDefaultVersion ( ) : string
return string the default version

GetForceAddXsiTypes() public method

Gets the setting of whether or not to add XSI types in the SOAP payload.
public GetForceAddXsiTypes ( ) : boolean
return boolean whether or not to add XSI types in the SOAP payload

GetForceHttpVersion() public method

Gets the version of the HTTP protocol to use regardless of PHP version.
public GetForceHttpVersion ( ) : float
return float the HTTP version that should be used

GetHeaderNames() public method

Gets the names of all registered request header elements.
public GetHeaderNames ( ) : array
return array the names of the request header elements

GetHeaderValue() public method

Gets the value for a registered request header element.
public GetHeaderValue ( string $key ) : string
$key string the name of the request header element
return string the value of the request header element or null if not found

GetLogsDirectory() public method

Gets the logs directory.
public GetLogsDirectory ( ) : string
return string the logs directory

GetOAuth2Handler() public method

Gets the OAuth2 handler for this user.
public GetOAuth2Handler ( ) : OAuth2Handler
return OAuth2Handler the OAuth2 handler for this user

GetOAuth2Info() public method

Gets the OAuth2 info for this user.
public GetOAuth2Info ( ) : array
return array the OAuth2 info for this user

GetServiceSoapClient() public method

Gets the service by its service name.
public GetServiceSoapClient ( string $serviceName, SoapClientFactory $serviceFactory ) : SoapClient
$serviceName string the service name
$serviceFactory SoapClientFactory the service factory
return SoapClient the instantiated service

GetSoapCompressionLevel() public method

Gets the SOAP compression level.
public GetSoapCompressionLevel ( ) : integer
return integer the SOAP compression level

GetUserAgentHeaderName() abstract protected method

Gets the appropriate user agent header name for the API this client library is targeting.
abstract protected GetUserAgentHeaderName ( ) : string
return string The user agent header name.

GetWsdlCacheType() public method

Gets the type of WSDL caching in use.
public GetWsdlCacheType ( ) : integer
return integer the type of WSDL caching in use

InitLogs() protected method

HTTP headers and SOAP XML are logged to the soap_xml.log file and all request information is logged to the request_info.log file under the logs directory.
protected InitLogs ( )

IsSoapCompressionEnabled() public method

Is SOAP compression enabled.
public IsSoapCompressionEnabled ( ) : boolean
return boolean is SOAP compression enabled

LoadSettings() public method

Loads the settings for this client library. If the settings INI file located at $settingsIniPath cannot be loaded, then the parameters passed into this method are used.
public LoadSettings ( string $settingsIniPath, string $defaultVersion, string $defaultServer, string $defaultLogsDir, string $logsRelativePathBase )
$settingsIniPath string the path to the settings INI file
$defaultVersion string the default version if the settings INI file cannot be loaded
$defaultServer string the default server if the settings INI file cannot be loaded
$defaultLogsDir string the default logs directory if the settings INI file cannot be loaded
$logsRelativePathBase string the relative path base for the logs directory

LogAll() public method

Configures the library to log all requests.
public LogAll ( )

LogDefaults() public method

Configures the library to log basic information about all requests and the full SOAP XML request and response only when an error occurs.
public LogDefaults ( )

LogErrors() public method

Configures the library to only log requests that return an error.
public LogErrors ( )

SetDefaultServer() public method

Sets the default server.
public SetDefaultServer ( string $defaultServer )
$defaultServer string the default server

SetDefaultVersion() public method

Sets the default version.
public SetDefaultVersion ( string $defaultVersion )
$defaultVersion string the default version

SetHeaderValue() public method

Sets the value for a request header.
public SetHeaderValue ( string $key, string $value )
$key string the name of the request header element
$value string the value for the request header element

SetOAuth2Handler() public method

Sets the OAuth2 handler for this user.
public SetOAuth2Handler ( array $oauth2Handler )
$oauth2Handler array the OAuth2 handler for this user

SetOAuth2Info() public method

Sets the OAuth2 info for this user.
public SetOAuth2Info ( array $oauth2Info )
$oauth2Info array the OAuth2 info for this user

ValidateOAuth2Info() protected method

Validates that the OAuth2 info is complete.
protected ValidateOAuth2Info ( )

__construct() protected method

Constructor for AdsUser.
protected __construct ( )

getIsIncludeUtilitiesInUserAgent() public method

public getIsIncludeUtilitiesInUserAgent ( ) : boolean
return boolean whether or not names of ads utilities being used will be included in the user agent

setIncludeUtilitiesInUserAgent() public method

public setIncludeUtilitiesInUserAgent ( boolean $isIncludeUtilitiesInUserAgent )
$isIncludeUtilitiesInUserAgent boolean whether ads utilities being used will be included in the user agent

updateClientLibraryUserAgent() public method

TODO(vtsao): The current contract requires that subclasses call this method in their constructor.
public updateClientLibraryUserAgent ( string $applicationName )
$applicationName string The application name that will appear in this header