423,516 Members | 2,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,516 IT Pros & Developers. It's quick & easy.

this code work on wamp server but not on my site web

P: 1
this is the error


Warning: simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found

this is the code :
Expand|Select|Wrap|Line Numbers
  1. Class Alexa_Api{
  2.  
  3.     private $output;
  4.  
  5.     public function __construct( $url )
  6.     {
  7.  
  8.         $custom_url = $url;
  9.         $url = "http://data.alexa.com/data?cli=10&url=$custom_url";
  10.  
  11.         $ch = curl_init($url);
  12.         curl_setopt($ch, CURLOPT_HEADER, false);
  13.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  14.         $contents = curl_exec($ch);
  15.  
  16.         $this->output = simplexml_load_string($contents);
  17.  
  18.         curl_close($ch);
  19.  
  20.     }
  21.  
  22.     public function GetGlobalRank()
  23.     {
  24.  
  25.         $popularity = json_decode( json_encode( $this->output->SD->POPULARITY ), TRUE );
  26.  
  27.         $popularity_info = $popularity['@attributes'];
  28.  
  29.         return $popularity_info;
  30.  
  31.     }
  32.  
  33.     public function GetCountryRank()
  34.     {
  35.         $country = json_decode( json_encode( $this->output->SD->COUNTRY ), TRUE );
  36.  
  37.         $country_info = $country['@attributes'];
  38.  
  39.         return $country_info;
  40.  
  41.     }
  42.   }
  43.  
  44.  
1 Week Ago #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.