Publisher Help Center
Search:  


PHP Sample Code

The Automated LinkGenerator is a Web Service that allows you to create LinkShare click links for any page on an advertiser's site. The code samples in this document demonstrate how to do this using PHP.

First, we need to create a page that allows the user to enter an Advertiser URL and an Advertiser ID, and to click on submit to get the results.

<html>
<head>
<title>LinkShare Automated LinkGenerator</title>
</head>
<body>
<form method="post" action="AutoLinkGenProc.php">
Sample to use the Automated LinkGenerator Web Service <br /><br />
Enter Advertiser URL:<input type="text" name="AdvURL"><br />
Enter Advertiser ID:<input type="text" name="mid"><br />
<input type="submit" value="submit" name="submit">
</form>
</body>
</html>


Here is what this will look like:



We also need a page to send the query to the LinkShare server and process the response.

This is the sample code demonstrating how to do this:

<html>
<body>

<?php
 
  "http://feed.linksynergy.com/createcustomlink.shtml?token=<token-ID>&mid=<MID>&murl=<URL-from-merchant>";
  $url = "http://feed.linksynergy.com/createcustomlink.shtml";
  $token = "5849bcc2fd3a5f3fd9dc2f7d9c08d8924143983a2745f393bf45534b171d9807"; //Change this to your token
  $advURL=$_POST["AdvURL"];
  $MID=$_POST["mid"];
  $resturl = $url."?"."token=".$token."&mid=".$MID."&murl=".$advURL;
   
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $resturl);
  
  $response=curl_exec($ch);

  if (curl_errno($ch))
    {
    print "Error: " . curl_error($ch);
    }
  else
   {
    print $response;
    curl_close($ch);
    }

?>
</body>
</html>


Here is the result this returns:

http://click.linksynergy.com/fs-bin/click?id=KgGHO0LswUU&subid=&offerid=102327.1&type=10&tmpid=2405&RD_PARM1=http%3A%2F%2Fwww.tigerdirect.com%2Fapplications%2FSearchTools%2Fitem-details.asp%3FEdpNo%3D2450694%2526Sku%3DA179-15081


You should be able to use this response to build an image link:

<a href=" http://click.linksynergy.com/fs-bin/click?id=KgGHO0LswUU&subid=&offerid=102327.1&type=10&tmpid=2405&RD_PARM1=http%3A%2F%2Fwww.tigerdirect.com%2Fapplications%2FSearchTools%2Fitem-details.asp%3FEdpNo%3D2450694%2526Sku%3DA179-15081"><IMG alt="TigerDirect" border="0" src="http://images.tigerdirect.com/skuimages/large/A179-1508CA-main-ca.jpg"></a>

Terms of Use
THE CODE SAMPLE (THE "CODE") IS BEING PROVIDED FREE OF CHARGE AND MERELY AS REFERENCE MATERIAL TO SUPPORT YOU IN BUILDING YOUR OWN CUSTOM APPLICATION TO FACILITATE YOUR USE OF CERTAIN OF LINKSHARE'S TOOLS, SERVICES OR RESOURCES IDENTIFIED HEREIN. BY ACCEPTING, INSTALLING OR OTHERWISE USING THE CODE, YOU HEREBY AGREE TO THE FOLLOWING TERMS:

THE CODE IS PROVIDED "AS IS, WHERE IS" AND "AS AVAILABLE."

EACH OF LINKSHARE AND ITS CORPORATE AFFILIATES, CONTRACTORS, LICENSORS, LICENSEES AND SUPPLIERS ("LINKSHARE RELATED PARTIES") HEREBY DISCLAIM ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY AS TO ACCURACY, MERCHANTABILITY, COMPLETENESS, CURRENTNESS, SECURITY, NON-INFRINGEMENT, TITLE, OR FITNESS FOR A PARTICULAR PURPOSE OF THE CODE OR THAT YOUR USE OF THE SAME WILL BE UNINTERRUPTED OR ERROR-FREE.

YOU AGREE THAT NONE OF LINKSHARE AND LINKSHARE RELATED PARTIES WILL BE LIABLE TO YOU (WHETHER IN CONTRACT OR BASED ON WARRANTY, NEGLIGENCE, TORT, STRICT LIABILITY OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER, INCLUDING ANY GENERAL, DIRECT, EXPECTATION, INDIRECT, INCIDENTAL, CONSEQUENTIAL, RELIANCE, PUNITIVE OR SPECIAL DAMAGES, INCLUDING LOSS OF REVENUE OR PROFITS, ARISING OUT OF OR RELATING TO THE CODE OR ANYTHING SET FORTH IN THESE TERMS AND CONDITION, INCLUDING ANY THIRD PARTY INFRINGEMENT CLAIMS, EVEN IF YOU OR LINKSHARE WAS AWARE THAT SUCH DAMAGES COULD RESULT.


Was this information helpful?
Thank you for rating this answer.
                 
User Opinions (8 votes) 87% thumbs up 12% thumbs down

Related Articles
No related articles were found.
Attachments


Continue