Advertisement
Guest User

Untitled

a guest
Feb 7th, 2014
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.99 KB | None | 0 0
  1. <?php
  2.  
  3. $affiliateid = 'zc9ig2Ef'; //Letters and numbers
  4. $trackingid = '96945214'; //numbers only
  5.  
  6. function UrlSigner($urlDomain, $urlPath, $partner, $key){
  7.  
  8. settype($urlDomain, 'String');
  9. settype($urlPath, 'String');
  10. settype($partner, 'String');
  11. settype($key, 'String');
  12.  
  13. $URL_sig = "hash";
  14. $URL_ts = "timestamp";
  15. $URL_partner = "aid";
  16.  
  17. $URLreturn = "";
  18. $URLtmp = "";
  19. $s = "";
  20. // get the timestamp
  21. $time = time();
  22.  
  23. // replace " " by "+"
  24. $urlPath = str_replace(" ", "+", $urlPath);
  25.  
  26. // format URL
  27. $URLtmp = $urlPath . "&" . $URL_partner . "=" . $partner . "&" . $URL_ts . "=" . $time;
  28.  
  29. // URL needed to create the tokken
  30. $s = $urlPath . "&" . $URL_partner . "=" . $partner . "&" . $URL_ts . "=" . $time . $key;
  31.  
  32. $tokken = "";
  33. $tokken = base64_encode(pack('H*', md5($s)));
  34. $tokken = str_replace(array("+", "/", "="), array(".", "_", "-"), $tokken);
  35.  
  36. $URLreturn = $urlDomain . $URLtmp . "&" . $URL_sig . "=" . $tokken;
  37.  
  38. return $URLreturn;
  39. }
  40.  
  41.   $querySearch = array("iPhone","Nokia+Lumia","iPhone+5","Nexus+5","Samsung+Galaxy+S4","sony+xperia","HTC");
  42.   $randQuery = rand(0, count($querySearch)-1);
  43.  
  44.   $request =  simplexml_load_file(UrlSigner('http://it.shoppingapis.kelkoo.com',  '/V3/productSearch?query=iphone&amp;category=100020213&amp;sort=default_ranking&amp;results=12&amp;show_subcategories=0&amp;show_refinements=0',  $trackingid, $affiliateid));
  45.  
  46.  
  47. ?>
  48.  
  49. <table style="width:100%; border:0; cellspacing:2px; cellpadding:2px; align:center">
  50.  
  51. <?php
  52.    
  53.     $result_counter = 12;
  54.     for( $i=0; $i < $result_counter; ++$i ) {  
  55.    
  56.     foreach ($request->Products->Product as $details) {
  57.              $Title = $details->Offer->Title;
  58.              $Image = $details->Offer->Images->Image->Url;
  59.              $Url = $details->Offer->Url;
  60.              $Price = $details->Offer->Price->Price;   
  61.              }    
  62.                      
  63.     if ($i % 3 == 0) {
  64.        
  65.         echo "<tr>";
  66.     }
  67.     echo '<td style="width:25%"><table style="width:100%; border:0; cellspacing:2px; cellpadding:2px; align:center">';
  68.     echo '<tr>';
  69.     echo '<td style="text-align:center; valign:top">';
  70.     echo '<a href="http://clk.tradedoubler.com/click?p=48396&amp;a=1820567&amp;url='.str_replace('&', "&amp;", $Url[$i]).'" target="_blank" title="Prezzi Cellulari" rel="nofollow"><img src="'.$Image[$i].'" style="border:0; width:60; height:60" alt="Prezzi Cellulari" /></a>';
  71.     echo '</td></tr><tr>';
  72.     echo '<td style="width:85%; text-align:center; height:1; valign:top">';
  73.     echo '<a class="linkadv" href="http://clk.tradedoubler.com/click?p=48396&amp;a=1820567&amp;url='.str_replace('&', "&amp;", $Url[$i]).'" target="_blank" rel="nofollow" title="'.$Title[$i].'">'.substr(str_replace(array(',','+','/'),array(", "," + "," / "),$Title[$i]." ..."), 0, 20).'</a>';
  74.     echo '</td></tr><tr>';
  75.     echo '<td style="width:85%; height:19; text-align:center; valign:bottom">';
  76.     echo '<b>&euro; '.$Price[$i].'</b></td>';
  77.     echo '</tr>';
  78.     echo '</table></td>';
  79.  
  80.     if($i % 3 == 2) {
  81.           echo '</tr>';
  82.     }
  83. }
  84. ?>
  85. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement