PHP script to demonstrate testimonials API usage
<?php
// create a new cURL resource
$ch = curl_init();
# Set the url to testimonials
$url = 'http://www.points2shop.com/webservice/testimonials';
// This key is required for all API REST calls and can be found in details of your application
$key = '6586df0367b681497ef77437f0c71c10ae38302e';
// set URL and HTTP header options
$options = array(CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_HTTPHEADER => array('X-Points2shop-Api-Key: ' . $key)
);
// Notice the space after 'Api-Key: '
curl_setopt_array($ch, $options);
// grab URL and pass it to the browser
$testimonials = curl_exec($ch);
# Check whether the response was valid
$curl_info = curl_getinfo($ch);
if ($curl_info['http_code'] != 200) {
echo "Unable to obtain information";
exit();
}
// decode the JSON
$testimonials_array = json_decode($testimonials);
// at this point, $testimonials_array will contain objects consisting of testimonial fields