Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     function getLastFM($url) {
  3.         $curl = curl_init($url);
  4.  
  5.         curl_setopt($curl , CURLOPT_HEADER, 0);
  6.         curl_setopt($curl , CURLOPT_RETURNTRANSFER, 1);
  7.         curl_setopt($curl , CURLOPT_URL, $url);
  8.  
  9.         if(curl_getinfo($curl, CURLINFO_HTTP_CODE) == '404') echo "ERROR 404!";
  10.  
  11.         $content = curl_exec($curl );
  12.        
  13.         if ($content === FALSE) {
  14.             throw new RuntimeException("cURL exception: ".curl_errno($curl).": ".curl_error($curl));
  15.         }
  16.        
  17.         curl_close($curl );
  18.  
  19.         return $content;
  20.     }
  21.  
  22.     $content = getLastFM('http://www.last.fm/user/robinpr_eu/now');
  23.     echo $content;
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement