Does Anyone Know how to Fire a Postback to Another Server using PHP?

131 Views Asked by At

I am dealing with an affiliate marketing company and after I gather the info from a sale that was referred to my site they want me to "fire a postback" to their server in teh following format:

https://track.my affilatecompany.com/da.ashx?advertiserid=12345&clickid=&orderamount=&ordernumber="

I tried assembling the loaded URL in PHP and echoing it to the browser window with JavaScript but the affiliate company doesn't accept that. They have literally no information in their help docs, just says "fire a postback server-to-server". Any assistance would be most appreciated. Thank you.

1

There are 1 best solutions below

2
Simon. On

You can use PHP Curl to make a POST request

This example will make the POST request to the affiliate. You can use the $response variable to determine if the request was successful.

<?php

   $url = "https://track.my affilatecompany.com/da.ashx?advertiserid=12345&clickid=&orderamount=&ordernumber=";
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($ch, CURLOPT_HEADER, false);
   curl_setopt($ch, CURLOPT_URL, $url);
   curl_setopt($ch, CURLOPT_POST, true);
   $response = curl_exec($ch);
   curl_close($ch);

 ?>