dolibarr 18.0.6
|
Public Member Functions | |
__construct ($url, $key, $debug=true) | |
PrestaShopWebservice constructor. | |
executeRequest ($url, $curl_params=array()) | |
Handles a CURL request to PrestaShop Webservice. | |
printDebug ($title, $content) | |
Output debug info. | |
getVersion () | |
Return version. | |
add ($options) | |
Add (POST) a resource. | |
get ($options) | |
Retrieve (GET) a resource. | |
head ($options) | |
Head method (HEAD) a resource. | |
edit ($options) | |
Edit (PUT) a resource. | |
Protected Member Functions | |
checkStatusCode ($status_code) | |
Take the status code and throw an exception if the server didn't return 200 or 201 code. | |
parseXML ($response) | |
Load XML from string. | |
Definition at line 32 of file PSWebServiceLibrary.class.php.
PrestaShopWebservice::__construct | ( | $url, | |
$key, | |||
$debug = true ) |
PrestaShopWebservice constructor.
Throw an exception when CURL is not installed/activated <?php require_once './PrestaShopWebservice.php'; try { $ws = new PrestaShopWebservice('http://mystore.com/', 'ZQ88PRJX5VWQHCWE4EE7SQ7HPNX00RAJ', false); // Now we have a webservice object to play with } catch (PrestaShopWebserviceException $ex) { echo 'Error : '.$ex->getMessage(); } ?>
string | $url | Root URL for the shop |
string | $key | Authentification key |
mixed | $debug | Debug mode Activated (true) or deactivated (false) |
Definition at line 72 of file PSWebServiceLibrary.class.php.
PrestaShopWebservice::add | ( | $options | ) |
Add (POST) a resource.
Unique parameter must take :
'resource' => Resource name
'postXml' => Full XML string to add resource<br>
Examples are given in the tutorial
array | $options | Options |
PrestaShopWebserviceException |
Definition at line 262 of file PSWebServiceLibrary.class.php.
References checkStatusCode(), executeRequest(), and parseXML().
|
protected |
PrestaShopWebservice::edit | ( | $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<br>
Examples are given in the tutorial
array | $options | Array representing resource to edit. |
PrestaShopWebserviceException |
Definition at line 398 of file PSWebServiceLibrary.class.php.
References checkStatusCode(), executeRequest(), and parseXML().
PrestaShopWebservice::executeRequest | ( | $url, | |
$curl_params = array() ) |
Handles a CURL request to PrestaShop Webservice.
Can throw exception.
string | $url | Resource name |
mixed | $curl_params | CURL parameters (sent to curl_set_opt) |
Definition at line 120 of file PSWebServiceLibrary.class.php.
References dol_syslog(), and printDebug().
PrestaShopWebservice::get | ( | $options | ) |
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<br>
<?php require_once './PrestaShopWebservice.php'; try { $ws = new PrestaShopWebservice('http://mystore.com/', 'ZQ88PRJX5VWQHCWE4EE7SQ7HPNX00RAJ', false); $xml = $ws->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(); } ?>
array | $options | Array representing resource to get. |
PrestaShopWebserviceException |
Definition at line 315 of file PSWebServiceLibrary.class.php.
References checkStatusCode(), executeRequest(), and parseXML().
PrestaShopWebservice::getVersion | ( | ) |
PrestaShopWebservice::head | ( | $options | ) |
Head method (HEAD) a resource.
array | $options | Array representing resource for head request. |
PrestaShopWebserviceException |
Definition at line 356 of file PSWebServiceLibrary.class.php.
References checkStatusCode(), and executeRequest().
|
protected |
Load XML from string.
Can throw exception
string | $response | String from a CURL response |
PrestaShopWebserviceException |
Definition at line 230 of file PSWebServiceLibrary.class.php.
PrestaShopWebservice::printDebug | ( | $title, | |
$content ) |
Output debug info.
string | $title | Title |
string | $content | Content |
Definition at line 207 of file PSWebServiceLibrary.class.php.
References dol_escape_htmltag().
Referenced by executeRequest().