473,385 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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.  
Oct 8 '18 #1
0 1373

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

Similar topics

1
by: FayeC | last post by:
I got this snippet online and for the life of me I can't seem to make it write the cookie.... The Flash has the labels mentioned in the code and I used the name=movie and the swconnect=true as...
2
by: blongmire | last post by:
.... I know just enough to be dangerous, but the real danger is that I might fall asleep and hit my head on my keyboard waiting for this code to finish executing. Some preliminaries: WinXP Pro,...
8
by: mheden | last post by:
Hello all, I'm using an Access 97 front-end with a SQL Server 2000 back-end. One particular bit of code runs a stored procedure to obtain a rowcount from one of the back-end tables. This works...
3
by: Anil | last post by:
hi will the following code work. typedef struct { unsigned char date; unsigned char sortie_num; unsigned int start_address; unsigned short offset; } sortie_data;
7
by: Peter Steele | last post by:
I have code to add a domain user to a local group but I'm not sure if it will work with NT domains or whether it will only work with Active Directory based systems. Here's the code: public void...
9
by: bhavik.patel | last post by:
Hi I have a rather simple question: I have following class definitions: class Base { public: virtual void display ()
3
by: anagram | last post by:
hi all... i found this code in some past discussion on this forum.i do not understand why operator overloading is necessary.if i remove it iam getting errors... #include <map> class Keys {...
3
by: xmail123 | last post by:
Why does this code work? I am new to C# and have been studying this piece of code. It loops through an Adjacency Matrix table to populate a tree view. I have two questions about why this code...
7
by: jharrison | last post by:
I'm finding it hard to make this code work in Python 3.0. Been looking at it for some time now: # import module for random functions import random # List of words for the computer to pick...
1
by: jomrjack | last post by:
Hi can I ask for a very important question? because I am wondering if how this code works? where I could place this code on MS Access to run this function. Can I make a module and paste this codes?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.