Clickbank API in php?

3.1k Views Asked by At

i need to get digital products from click bank, so am using their API to get products, unfortunately given example code given by them are not working, am using CURL to do this ,

code is below :

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://api.clickbank.com/rest/1.3/products/list");
curl_setopt($ch, CURLOPT_HEADER, true); 
curl_setopt($ch, CURLOPT_HTTPGET, true); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/xml", "Authorization:DEV-KEY:API-KEY"));
$result = curl_exec($ch);
curl_close($ch);

print $result;

?>

but i got the below error

HTTP/1.1 400 Bad Request Date: Thu, 21 Feb 2013 05:20:47 GMT Server: Apache/2.2.23 (FreeBSD) mod_jk/1.2.37 mod_ssl/2.2.23 OpenSSL/0.9.8x Vary: Accept-Encoding Connection: close Transfer-Encoding: chunked Content-Type: text/plain The API call (/api/rest/1.3/products/list) requires parameters which are missing : [site]1

have any one got this error before ?

2

There are 2 best solutions below

0
On

Try This:

<?php
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,"https://api.clickbank.com/rest/1.3/products/list?site=<your unique affiliate id>");
    curl_setopt($ch, CURLOPT_HEADER, true); 
    curl_setopt($ch, CURLOPT_HTTPGET, true); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/xml", "Authorization:DEV-KEY:API-KEY"));
    $result = curl_exec($ch);
    curl_close($ch);

    print $result;

    ?>
1
On

It's expecting a parameter called site. Please see the docs here: https://api.clickbank.com/rest/1.3/products