Advertisement
allshared

Untitled

Dec 9th, 2011
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.23 KB | None | 0 0
  1.  
  2. Account 961712
  3. Total Paid $0.00
  4. Clicks Balance $0.00
  5. Conversion Balance $0.00
  6. LOGOUT |SUPPORT
  7. $Recommend
  8.  
  9.  
  10. ACCOUNT MANAGEMENT
  11. MANAGE BIDVERTISERS
  12. MANAGE TOOLBARS
  13. MANAGE XML
  14. REPORTS
  15. XML Feeds Center Add new XML feed Daily Report Summary Report Geo Report
  16. PHP Feed Implementation
  17.  
  18.  
  19. PHP Sample XML Feed Implementation:
  20.  
  21. Sample PHP code is provided for a quick implementation of our XML feed - you can use the following PHP code as an implementation sample to get you started:
  22.  
  23. Your XML Feed Request Format:
  24. <?php
  25.  
  26. ini_set('display_errors', 'On');
  27. error_reporting(E_ALL | E_STRICT);
  28.  
  29. $pid = '425245';
  30. $bid = '1065331';
  31. $ownid = 'xml1'; // if sending traffic with sub affiliates. modify to fit your needs.
  32. $maxcount = '5'; // max number of results to return. modify to fit your needs.
  33.  
  34. $u_agnt = urlencode($_SERVER['HTTP_USER_AGENT']); // user agent. do not modify
  35.  
  36. $cip = $_SERVER['REMOTE_ADDR']; // IP address of user requesting search. do not modify
  37.  
  38.  
  39. // acquire search terms
  40. if(isset($_REQUEST['terms']) && !empty($_REQUEST['terms'])){
  41. $terms = urlencode($_REQUEST['terms']);
  42. }else{
  43. echo get_search_form();
  44. exit;
  45. }
  46.  
  47. $bvref = trim($_SERVER['HTTP_REFERER']);
  48.  
  49. $url = "http://bdv.bidvertiser.com/BidVertiser.dbm?pid=$pid&bid=$bid&Kterm=$terms&cip=$cip&maxcount=$maxcount"
  50. ."&bvref=$bvref&u_agnt=$u_agnt&ownid=$ownid&xml=1";
  51.  
  52. $result = call_xml($url, $u_agnt);
  53.  
  54.  
  55. // check if results came back from the feed
  56. if (strstr($result, "title") === FALSE) { $msg = "No results found.";}else{$msg="";}
  57.  
  58. echo get_search_form($terms, $msg);
  59.  
  60. echo format_result($result);
  61.  
  62.  
  63.  
  64. /*
  65. Parses and display the result of the XML feed
  66. @param $result - The result of the XML feed
  67. @returns - the HTML version of the XML results
  68. */
  69. function format_result($result){
  70. $title = array();
  71. $url = array();
  72. $redirect = array();
  73. $description = array();
  74.  
  75. preg_match_all('#<title><!\[CDATA\[(.*?)\]\]></title>#', $result, $title);
  76. preg_match_all('#<displayURL><!\[CDATA\[(.*?)\]\]></displayURL>#', $result, $url);
  77. preg_match_all('#<redirect><!\[CDATA\[(.*?)\]\]></redirect>#', $result, $redirect);
  78. preg_match_all('#<description><!\[CDATA\[(.*?)\]\]></description>#', $result, $description);
  79.  
  80. $items = count($title[1]);
  81. $rv = '';
  82. for($i=0; $i<$items; $i++){
  83. $rv .= '
  84. <li>
  85. <a href='.$redirect[1][$i].'>'.$title[1][$i].'</a><br>
  86. '.$description[1][$i].'<br>'.
  87. $url[1][$i].
  88. '<br><br></li>';
  89.  
  90. }// end for
  91. return $rv;
  92. }// end function
  93.  
  94. /*
  95. Obtains the search form
  96. @param $terms - the default search term
  97. @param $msg - alert message
  98.  
  99. @returns - The HTML form
  100. */
  101. function get_search_form($terms="", $msg=""){
  102. if (!empty($msg)) {
  103. $msg = "<font color='red'><b>$msg</b></font><hr>";
  104. }// end if
  105.  
  106. $form = "
  107. $msg
  108. Please enter your search term
  109. <br><br>
  110. <form method='post' action='".$_SERVER["PHP_SELF"]."'>
  111. Keyword: <input type='text' name='terms' value='$terms'>
  112. <br>
  113. <br>
  114. <input type='submit' value='Search'>
  115. </form><hr>
  116. ";
  117. return $form;
  118.  
  119. }// end function
  120.  
  121. /*
  122. Calls the XML feed
  123. @param $url - the URL of the feed to call
  124. @param $ua - The user agent
  125.  
  126. @returns - the result of the query from the feed
  127. */
  128. function call_xml($url, $ua="")
  129. {
  130. $hostname=trim($_SERVER['HTTP_HOST']);
  131.  
  132. $ch = curl_init($url);
  133. curl_setopt($ch, CURLOPT_USERAGENT, $ua);
  134. curl_setopt($ch, CURLOPT_REFERER, $hostname);
  135. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  136. curl_setopt($ch, CURLOPT_HEADER, 0);
  137. $result = curl_exec($ch);
  138. curl_close($ch);
  139. return $result;
  140. }// end function
  141.  
  142.  
  143. ?>
  144.  
  145.  
  146.  
  147. Copyright © 2011, BidVertiser.com All rights reserved. BidVertiser.com is a division of Bpath, LTD.
  148.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement