Reply to this topicStart new topic
Off-site access restriction from on-site PHP, Trying to use 'file' or 'file_get_contents'
info@...
post Nov 17 2009, 07:02 PM
Post #1
Group: Members
Posts: 2



Hi Guys,
I am TRYING to access an external web server from my Yahoo hosted PHP script. I know the script is valid as I can easily run it from my localhost. But when I copy the script to my site hosted on Yahoo, the script fails, and I know it fails; whenever the file or file_get_contents PHP function is used. For example, $array = file('www.yahoo.com'); or $string = file_get_contents("www.google.com"); (Yahoo & Google are here only for example). I really get the feeling that there is a permissioning issue on my/all (?) Yahoo hosted sites. Or is it a Yahoo firewall? This is really concerning me as I want to access important information hosted on an external (from Yahoo) site. This is a real show stopper.
blink.gif
Urgent answer required (trex_4321 at yahoo dot com), if possible. Otherwise off to another hosting service.
Go to the top of the page
 
+Quote Post
Sony AK
post Nov 23 2009, 07:08 PM
Post #2
Group: Members
Posts: 3



QUOTE (info@... @ Nov 17 2009, 07:02 PM) *
Hi Guys,
I am TRYING to access an external web server from my Yahoo hosted PHP script. I know the script is valid as I can easily run it from my localhost. But when I copy the script to my site hosted on Yahoo, the script fails, and I know it fails; whenever the file or file_get_contents PHP function is used. For example, $array = file('www.yahoo.com'); or $string = file_get_contents("www.google.com"); (Yahoo & Google are here only for example). I really get the feeling that there is a permissioning issue on my/all (?) Yahoo hosted sites. Or is it a Yahoo firewall? This is really concerning me as I want to access important information hosted on an external (from Yahoo) site. This is a real show stopper.
blink.gif
Urgent answer required (trex_4321 at yahoo dot com), if possible. Otherwise off to another hosting service.


Have you try using cURL?

Best regards,
Sony AK
http://www.sony-ak.com
Go to the top of the page
 
+Quote Post
rnd@...
post Nov 25 2009, 05:57 AM
Post #3
Group: Members
Posts: 1



QUOTE (info@... @ Nov 17 2009, 07:02 PM) *
Hi Guys,
I am TRYING to access an external web server from my Yahoo hosted PHP script. I know the script is valid as I can easily run it from my localhost. But when I copy the script to my site hosted on Yahoo, the script fails, and I know it fails; whenever the file or file_get_contents PHP function is used. For example, $array = file('www.yahoo.com'); or $string = file_get_contents("www.google.com"); (Yahoo & Google are here only for example). I really get the feeling that there is a permissioning issue on my/all (?) Yahoo hosted sites. Or is it a Yahoo firewall? This is really concerning me as I want to access important information hosted on an external (from Yahoo) site. This is a real show stopper.
blink.gif
Urgent answer required (trex_4321 at yahoo dot com), if possible. Otherwise off to another hosting service.


In php.ini the "allow_url_fopen" value is changed to 0 (default is 1) causing file_get_contents(URL) to fail, affecting YAHOO! API access.
Go to the top of the page
 
+Quote Post
ronp
post Jan 11 2010, 12:47 PM
Post #4
Group: Members
Posts: 1



QUOTE (rnd@... @ Nov 25 2009, 05:57 AM) *
In php.ini the "allow_url_fopen" value is changed to 0 (default is 1) causing file_get_contents(URL) to fail, affecting YAHOO! API access.


I understand that, but I can't understand why curl doesn't work on external files.

CODE
function  getfile($url)
{
$ch = curl_init($url);
$fp=fopen("catalog1.xml","w") or die("can't open catalog1.xml");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_exec($ch);
curl_close($ch);
fclose($fp);
}


This function only works on files that fopen will work with not external files. Can't figure out why. Help!
Go to the top of the page
 
+Quote Post
« Next Oldest · PHP Development · Next Newest »
 

Reply to this topicStart new topic

 



rss YDN Forum RSS feeds

YDN Content Copyright © 2010 Yahoo! Inc. All rights reserved. Copyright | Privacy Policy

Help us continue to improve the Yahoo! Developer Network - Send Your Suggestions