Sixem

PHP Get Adventure's Log Feed Using cURL

Sep 11th, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. function Grab_Adventures($username){
  2.     $url = 'http://services.runescape.com/m=adventurers-log/rssfeed?searchName=' . $username;
  3.     $ch = curl_init($url);
  4.     curl_setopt( $ch, CURLOPT_POST, false );
  5.     curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
  6.     curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7");
  7.     curl_setopt( $ch, CURLOPT_HEADER, false );
  8.     curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
  9.     $data = curl_exec($ch);
  10.     $x = new SimpleXmlElement($data);
  11.     foreach($x->channel->item as $entry) { 
  12.         $entry_target = $entry->title;
  13.         $entry_date = split('00', $entry->pubDate);
  14.         $entry_description = $entry->description;      
  15.         echo '<div id="al_entry">' . $entry_target . "" . '</div>';
  16.         echo '<div id="al_date">' . $entry_description . "" . '</div>';
  17.         echo '<div id="al_date">' . $entry_date[0] . "" . '</div>';
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment