-2

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.

Mike B
  • 15
  • 4
  • I suspect they just mean to make a GET request to that URL. Whether that request should come from the browser/user or from server-side code is between you and that third party. (Edit: Though *"server-to-server"* suggests the latter.) – David Dec 12 '22 at 21:25

1 Answers1

1

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);

 ?>
Simon.
  • 1,886
  • 5
  • 29
  • 62
  • Thank you for sharing this actual code example which is very helpful. The server response says "The Click ID is required for a valid conversion". I have the click ID stored in a PHP variable named $refid. The code above does not pass the click ID stored in PHP variable $refid in any way which is the problem. Same with the other parameters, specifically ordernumber and orderamount. – Mike B Dec 13 '22 at 09:29
  • @MikeB You can drop variables inline with the `$url` definition like `ordernumber=$refid";` – Simon. Dec 13 '22 at 19:51