• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Runnig PHP from PHP

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

mccoyn

Senior Member
Joined
Nov 17, 2003
Location
Michigan, USA
I want to read in the XML from an RSS feed generated by WordPress. The feed is generated by a PHP script with a URL like www.example.com/blog/?feed=rss2 I would like my new PHP script to get the results from the URL so I can process it.

I tried calling file_get_contents(/blog/?feed=rss2), but it didn't like that. Anyone know how to do this?
 
Make sure allow_url_fopen is set to True in the php.ini file. Other than that more details would be helpful.

Web Server (apache, iis, ...)
OS (Windows, Linux, ...)
PHP version
Specific error you are getting.
 
Thanks, that's exactly what I needed. I didn't think my host would let me change that setting, but I was able to find the php.ini file and change it. Here is what my code looks like that is working after that change.

Code:
<?php

$file0 = 'http://www.example.com/blog/?feed=rss2';
$source0 = file_get_contents($file0);

echo $source0;
?>

I'm using Apache, but I'm not sure what version of PHP it has.
 
Just out of curiosity for a problem I'm having...

Can you use change your $file0 variable to pull a page over https? No biggie if you can't or don't want to, I'm just having a problem using file_get_contents with a https url.
 
Just out of curiosity for a problem I'm having...

Can you use change your $file0 variable to pull a page over https? No biggie if you can't or don't want to, I'm just having a problem using file_get_contents with a https url.
I tried it and got this error:

Code:
Notice: file_get_contents() [function.file-get-contents]: Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in C:\www\test2.php on line 3

Warning: file_get_contents(https://apps.asu.edu/CitrixLogonPoint/Apps/) [function.file-get-contents]: failed to open stream: Invalid argument in C:\www\test2.php on line 3
 
Thanks kayson. I'm just getting a blank page. Something isn't right in my config. If I ask anymore about this I'll start a new thread.
 
Back