Hi guys, I'm trying cancel a clickbank order using API, but no success, i'm using following code, ---------------- $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.clickbank.com/rest/1.2/tickets/R6SDFE9L?type=cncl&reason=ticket.type.cancel.7"); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/xml", "Authorization: DEV-removed:API-removed")); $result = curl_exec($ch); curl_close($ch); print $result; ------------------- If any one did it before please give me a hand, Thank you
The problem was two prong. I am running PHP 5.2.4 which has a bug accepting custom headers. I found this code, which worked perfectly. if(version_compare(PHP_VERSION, '5.3.0') == -1){ ini_set('user_agent', 'PHP-SOAP/' . PHP_VERSION . "\r\n" . $options['header']); } Curl would not work. Period. I tried everything. I really have no idea why. Here is the final code I ended up with, which works perfectly. This interfaces with the Clickbank API via POST. I hope this helps a lot of people. <?php $options = array('http'=>array('method'=>"POST",'header'=>"Accept: application/xml\r\n"."Authorization: DEV-key-here:API-key-here\r\n")); if(version_compare(PHP_VERSION,'5.3.0')==-1){ ini_set('user_agent','PHP-SOAP/'. PHP_VERSION ."\r\n". $options['header']);} $context = stream_context_create($options); $xml = file_get_contents('https://api.clickbank.com/rest/1.2/tickets/VZR9RYE3?reason=ticket.type.cancel.7&type=cncl',false,$context); ?>