...

View Full Version : Getting external XML data



itsjareds
07-24-2008, 11:31 PM
I am using Yahoo! BOSS search to generate the search for my site, but I'm having trouble getting the data from the XML file.

The search is done on yahoo's site, boss.yahooapis.com, and I need to get information from their site to mine.

The way I am trying to get the information is by using fopen("URL_HERE", "r");

But when I load the page with the search, a PHP error comes up saying:

URL file-access is disabled in the server configuration in [my directory] on line 35

How could I fixed this or do a workaround? I'm not sure I can change my server configuration because I am using subdomain hosting.

mlseim
07-25-2008, 01:34 AM
Your webhost does not allow "fopen" ... this is for security reasons.
An alternate way (that they most likely recommend is PHP CURL method).

See this example script on how to read an XML file using CURL.
It's all about reading an XML file to get the weather conditions,
but the idea is the same. In fact, you can copy and put this
script on your website to test it out.

http://www.catpin.com/weather

For more information about CURL, search Google for: PHP CURL tutorial

itsjareds
07-25-2008, 02:01 AM
Seems like the right choice, but now I get the error message:

Fatal error: Call to undefined function curl_init() in /home/www/[my_directory]/search.php on line 3

Is this because my server might have an out-of-date PHP version?

Fou-Lu
07-25-2008, 09:20 AM
No, it means you don't have the libcurl library installed. I don't do a lot of remote work, but the only ones I've used are fopen and curl, so without either I'm not certain you have a workaround besides finding a new host of course.

mlseim
07-25-2008, 01:56 PM
You need to have PHP5 for CURL.

djm0219
07-25-2008, 02:03 PM
Not true mlseim. cURL support was added in PHP 4.0.2.

mlseim
07-25-2008, 08:52 PM
Dave ... you are right ... I just read documentation with my webhost ...
they didn't have it enabled with PHP4, but they did with PHP5. That's when
they turned off "fopen" -- nobody can enable that, even with php.ini

[or they didn't have the library installed or enabled?]

Anyhow, cURL now works fine for me (with PHP5).

I guess each webhost sort of does their own thing.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum