PHP 클래스 PrestaShopWebservice

파일 보기 프로젝트 열기: prestashop/prestashop-webservice-lib 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$debug is debug activated
$key Authentification key
$url Shop URL
$version PS version

공개 메소드들

메소드 설명
__construct ( string $url, string $key, mixed $debug = true ) PrestaShopWebservice constructor. Throw an exception when CURL is not installed/activated getMessage(); } ?>
add ( array $options ) : SimpleXMLElement Add (POST) a resource

Unique parameter must take :

'resource' => Resource name
'postXml' => Full XML string to add resource

Examples are given in the tutorial

delete ( array $options ) Delete (DELETE) a resource.
edit ( array $options ) Edit (PUT) a resource

Unique parameter must take :

'resource' => Resource name ,
'id' => ID of a resource you want to edit,
'putXml' => Modified XML string of a resource

Examples are given in the tutorial

get ( array $options ) : SimpleXMLElement Retrieve (GET) a resource

Unique parameter must take :

'url' => Full URL for a GET request of Webservice (ex: http://mystore.com/api/customers/1/)
OR
'resource' => Resource name,
'id' => ID of a resource you want to get

get(array('resource' => 'orders', 'id' => 1)); Here in $xml, a SimpleXMLElement object you can parse foreach ($xml->children()->children() as $attName => $attValue) echo $attName.' = '.$attValue.'
'; } catch (PrestaShopWebserviceException $ex) { echo 'Error : '.$ex->getMessage(); } ?>
getVersion ( )
head ( array $options ) : SimpleXMLElement Head method (HEAD) a resource
printDebug ( $title, $content )

보호된 메소드들

메소드 설명
checkStatusCode ( integer $status_code ) Take the status code and throw an exception if the server didn't return 200 or 201 code
executeRequest ( string $url, mixed $curl_params = [] ) : array Handles a CURL request to PrestaShop Webservice. Can throw exception.
parseXML ( string $response ) : SimpleXMLElement Load XML from string. Can throw exception

메소드 상세

__construct() 공개 메소드

PrestaShopWebservice constructor. Throw an exception when CURL is not installed/activated getMessage(); } ?>
public __construct ( string $url, string $key, mixed $debug = true )
$url string Root URL for the shop
$key string Authentification key
$debug mixed Debug mode Activated (true) or deactivated (false)

add() 공개 메소드

Add (POST) a resource

Unique parameter must take :

'resource' => Resource name
'postXml' => Full XML string to add resource

Examples are given in the tutorial

public add ( array $options ) : SimpleXMLElement
$options array
리턴 SimpleXMLElement status_code, response

checkStatusCode() 보호된 메소드

Take the status code and throw an exception if the server didn't return 200 or 201 code
protected checkStatusCode ( integer $status_code )
$status_code integer Status code of an HTTP return

delete() 공개 메소드

Unique parameter must take :

'resource' => Resource name
'id' => ID or array which contains IDs of a resource(s) you want to delete

delete(array('resource' => 'orders', 'id' => 1)); Following code will not be executed if an exception is thrown. echo 'Successfully deleted.'; } catch (PrestaShopWebserviceException $ex) { echo 'Error : '.$ex->getMessage(); } ?>
public delete ( array $options )
$options array Array representing resource to delete.

edit() 공개 메소드

Edit (PUT) a resource

Unique parameter must take :

'resource' => Resource name ,
'id' => ID of a resource you want to edit,
'putXml' => Modified XML string of a resource

Examples are given in the tutorial

public edit ( array $options )
$options array Array representing resource to edit.

executeRequest() 보호된 메소드

Handles a CURL request to PrestaShop Webservice. Can throw exception.
protected executeRequest ( string $url, mixed $curl_params = [] ) : array
$url string Resource name
$curl_params mixed CURL parameters (sent to curl_set_opt)
리턴 array status_code, response

get() 공개 메소드

Retrieve (GET) a resource

Unique parameter must take :

'url' => Full URL for a GET request of Webservice (ex: http://mystore.com/api/customers/1/)
OR
'resource' => Resource name,
'id' => ID of a resource you want to get

get(array('resource' => 'orders', 'id' => 1)); Here in $xml, a SimpleXMLElement object you can parse foreach ($xml->children()->children() as $attName => $attValue) echo $attName.' = '.$attValue.'
'; } catch (PrestaShopWebserviceException $ex) { echo 'Error : '.$ex->getMessage(); } ?>
public get ( array $options ) : SimpleXMLElement
$options array Array representing resource to get.
리턴 SimpleXMLElement status_code, response

getVersion() 공개 메소드

public getVersion ( )

head() 공개 메소드

Head method (HEAD) a resource
public head ( array $options ) : SimpleXMLElement
$options array Array representing resource for head request.
리턴 SimpleXMLElement status_code, response

parseXML() 보호된 메소드

Load XML from string. Can throw exception
protected parseXML ( string $response ) : SimpleXMLElement
$response string String from a CURL response
리턴 SimpleXMLElement status_code, response

printDebug() 공개 메소드

public printDebug ( $title, $content )

프로퍼티 상세

$debug 보호되어 있는 프로퍼티

is debug activated
protected $debug

$key 보호되어 있는 프로퍼티

Authentification key
protected $key

$url 보호되어 있는 프로퍼티

Shop URL
protected $url

$version 보호되어 있는 프로퍼티

PS version
protected $version