PHP Class ApiMethods

Supported Version: PHP >= 5.0
See also: http://wiki.zanox.com/en/Web_Services
See also: http://apps.zanox.com
Author: Thomas Nicolai ([email protected])
Author: Lars Kirchhoff ([email protected])
Show file Open project: fubralimited/php-oara

Public Methods

Method Description
__construct ( string $protocol, string $version ) : void Constructor: Sets the api version and protocol
doRestfulRequest ( array $resource, $parameter = false, string $body = false ) : string Performs REST request.
doSoapRequest ( $service, string $method, array $params = [] ) : object Performs SOAP request.
enableCompression ( ) : void Set http protocol type
getProtocol ( ) : string Returns api protocol type
getVersion ( ) : string Sets the api version and protocol
serialize ( $rootName, $itemArray, $attr = [] ) : void Serializes item.
setConnectId ( string $connectId ) : void Set connectId
setHttpProtocol ( $httpProtocol ) : void Set http protocol type
setProtocol ( string $protocol ) : void Set api protocol type
setProxy ( string $host, integer $port, string $login, string $password ) : void Set http protocol type
setPublicKey ( $publicKey ) : void Set SecretKey
setRestfulAction ( $verb ) : void Sets the HTTP RESTful action verb.
setSecretKey ( string $secretKey ) : void Set SecretKey
setSecureApiCall ( $status = false ) : void Enables the API authentication.
setVersion ( string $version ) : void Sets the api version
unserialize ( string $string ) : void Unserializes item.

Private Methods

Method Description
getContentType ( ) : string Returns restful content type
getRestfulPath ( ) : string Returns restful api endpoint path
getWsdlUrl ( string $service ) : string Returns wsdl api endpoint
httpRequest ( string $uri, string $header, string $body = false ) : mixed HTTP REST Connection (GET/POST)
isValidHeader ( $responseHeader ) : string Returns if http response is valid.

Method Details

__construct() final public method

Constructor: Sets the api version and protocol
final public __construct ( string $protocol, string $version ) : void
$protocol string api protocol type
$version string api version
return void

doRestfulRequest() public method

The function creates the RESTful request URL out of the given resource URI and the given REST interface. A REST URI for example to request a program with the id 49 looks like this: /programs/program/49
public doRestfulRequest ( array $resource, $parameter = false, string $body = false ) : string
$resource array RESTful resource e.g. /programs
$body string HTTP xml body message
return string $result returns http response

doSoapRequest() public method

Performs SOAP request.
public doSoapRequest ( $service, string $method, array $params = [] ) : object
$method string soap service
$params array soap method parameter
return object soap result object or false on error

enableCompression() final public method

Set http protocol type
final public enableCompression ( ) : void
return void

getProtocol() final public method

Returns api protocol type
final public getProtocol ( ) : string
return string api protocol type

getVersion() final public method

Sets the api version and protocol
final public getVersion ( ) : string
return string api version

serialize() final public method

Transforms array into json or xml string while using the parser class. This is neccessary in order to update or create new items.
final public serialize ( $rootName, $itemArray, $attr = [] ) : void
return void

setConnectId() final public method

Set connectId
final public setConnectId ( string $connectId ) : void
$connectId string zanox connectId
return void

setHttpProtocol() final public method

Set http protocol type
final public setHttpProtocol ( $httpProtocol ) : void
return void

setProtocol() final public method

Set api protocol type
final public setProtocol ( string $protocol ) : void
$protocol string api protocol type
return void

setProxy() final public method

Set http protocol type
final public setProxy ( string $host, integer $port, string $login, string $password ) : void
$host string proxy host name
$port integer proxy port
$login string proxy login
$password string proxy password
return void

setPublicKey() final public method

Set SecretKey
final public setPublicKey ( $publicKey ) : void
return void

setRestfulAction() final public method

The given action might be GET, POST, PUT or DELETE. Be aware that no any action can be performed on any resource.
final public setRestfulAction ( $verb ) : void
return void

setSecretKey() final public method

Set SecretKey
final public setSecretKey ( string $secretKey ) : void
$secretKey string zanox secret key
return void

setSecureApiCall() final public method

Authentication is only required and therefore enabled for some privacy related functions like accessing your profile or reports.
final public setSecureApiCall ( $status = false ) : void
return void

setVersion() final public method

Sets the api version
final public setVersion ( string $version ) : void
$version string api version
return void

unserialize() final public method

Transforms json or xml string into array while using the parser class.
final public unserialize ( string $string ) : void
$string string xml or json string
return void