fetch twitter content using simpleXmlElement in php fails

132 Views Asked by At

I had googled a code to fetch a public twitter content, it work fine when on my localhost but when I put it online on a hosted server, it does not seem to respond at all! Code is as below.

For example url ='https://twitter.com/#!/NatureMagazine'

if($entered['domain']=='twitter.com')
{
    $baseName = basename($url);
    // HINT Code works fine up to here but after this statement, nothing comes out

    $sXML = new SimpleXMLElement('http://twitter.com/users/show.xml?screen_name='.$baseName, NULL, TRUE);

    // TRUE specifies that data is a path or URL to an XML document instead of string data.
    $screen_name                = $sXML->screen_name;
    $location                   = $sXML->location;
    $description                = $sXML->description;
}

Note: The same code works as expected on my local system.

1

There are 1 best solutions below

2
On

Note: Before PHP 5.1.2, --enable-simplexml is required to enable this extension.

Do a phpinfo() to check if libxml extension is ON in your server environment.

Share more info about that exactly is the problem. Because from code, you have not placed status checkers to help you debug along the way.

I hope the exit(); is not exactly been uploaded to the server.