error with simple xml load file

491 views
Skip to first unread message

oscarva

unread,
Jul 25, 2009, 2:05:25 AM7/25/09
to Twitter Development Talk
I am tring to do a Api call using simple xml and twitter search API.

$rss = simplexml_load_file('http://search.twitter.com/search.atom?
q=Google');
foreach ($rss->channel->item as $item){
$title = utf8_decode($item->title);
$url = $item->link;
}

The error log tells me the following:

PHP Warning: simplexml_load_file() [<a href='function.simplexml-load-
file'>function.simplexml-load-file</a>]: I/O warning : failed to load
external entity &quot;http://search.twitter.com/search.atom?
q=Google&quot; in /home/xxx/public_html/test/status.php on line 10
[error] [client 166.210.xxx.xxx] PHP Warning: simplexml_load_file
(http://search.twitter.com/search.atom?q=Google) [<a
href='function.simplexml-load-file'>function.simplexml-load-file</a>]:
failed to open stream: Connection timed out in /home/xxx/public_html/
test/status.php on line 10

PHP Version 5.2.8

This only happens on my server, since in local working properly. :(

Please Help. Thaks ;)

oscarva

unread,
Jul 27, 2009, 7:45:38 PM7/27/09
to Twitter Development Talk
Please help :(

JDG

unread,
Jul 27, 2009, 11:17:41 PM7/27/09
to twitter-deve...@googlegroups.com
does your hosting service allow remote connections to be made? that is, can you use similar code to connect to any other sites?
--
Internets. Serious business.

jmathai

unread,
Jul 28, 2009, 12:23:34 AM7/28/09
to Twitter Development Talk
JDG is probably correct.

$ch = curl_init('http://search.twitter.com/search.atom?q=Google');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
$sXml = simplexml_load_string($result);
var_dump($sXml);

oscarva

unread,
Jul 28, 2009, 10:57:15 PM7/28/09
to Twitter Development Talk
The result:

bool(false)

Thanks jmathai :)

oscarva

unread,
Jul 28, 2009, 10:56:32 PM7/28/09
to Twitter Development Talk
Yes JDG im used youtube api, yelp api, google api, technorati, and
more. and all works correctly, I just happened to twitter :(

On 27 jul, 22:17, JDG <ghil...@gmail.com> wrote:
> does your hosting service allow remote connections to be made? that is, can
> you use similar code to connect to any other sites?
>
>
>
> On Sat, Jul 25, 2009 at 00:05, oscarva <osca...@gmail.com> wrote:
>
> > I am tring to do a Api call using simple xml and twitter search API.
>
> > $rss = simplexml_load_file('http://search.twitter.com/search.atom?
> > q=Google' <http://search.twitter.com/search.atom?%0Aq=Google%27>);
> > foreach ($rss->channel->item as $item){
> >    $title = utf8_decode($item->title);
> >    $url = $item->link;
> > }
>
> > The error log tells me the following:
>
> > PHP Warning:  simplexml_load_file() [<a href='function.simplexml-load-
> > file'>function.simplexml-load-file</a>]: I/O warning : failed to load
> > external entity &quot;http://search.twitter.com/search.atom?
> > q=Google&quot <http://search.twitter.com/search.atom?%0Aq=Google">; in

chepe263

unread,
Aug 30, 2009, 5:22:28 PM8/30/09
to Twitter Development Talk
Hello, i have a question, How use it with xml api format??? See, i'm
using the http://twitter.com/statuses/friends_timeline.xml to get the
friends timeline for my app but i don't know how use it the data with
SimpleXML

Please help!!

chepe263

Adam Shannon

unread,
Aug 30, 2009, 9:47:06 PM8/30/09
to twitter-deve...@googlegroups.com
You need to allow PHP to access 3rd party (external) domains and grab files from them.

In your php.ini you should change this:

allow_url_fopen = Off

To:

allow_url_fopen = On

Also, if your host allows you to place php.ini files in the directory just put this in a new php.ini file.
[PHP]
allow_url_fopen = On
--
- Adam Shannon ( http://ashannon.us )
Reply all
Reply to author
Forward
0 new messages