PHP Script To Demonstrate Offers API Usage

Sign up FREE & get 250 points



<?php

// create a new cURL resource
$ch = curl_init();
$url = 'http://www.points2shop.com/webservice/offers';

// This key is required for all API REST calls and can be found in details of your application 
$key = 'c5a6ae5c570bb3bbb20fdba95b97174f3dbb3913';


// 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
$offers = 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
$offers_list = json_decode($offers);
// at this point, $offers_list will contain objects consisting of offers fields


Back to REST API Usage

Login with your social network:
Log in with your account: