Notices

Overclockers Forums > Software > Programming Tips and Tricks
Programming Tips and Tricks
Forum Jump

Runnig PHP from PHP

Post Reply New Thread Subscribe Search this Thread
 
 
Thread Tools
Old 02-09-08, 04:14 PM Thread Starter   #1
mccoyn
Senior Member

 
mccoyn's Avatar 

Join Date: Nov 2003
Location: Michigan, USA

 
Runnig PHP from PHP


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?

__________________
Once there was a caterpillar who had commas for legs. Which meant he had to allow a literary pause after each step. The other caterpillars really respected him for it and he came to have quite a commanding presence. Oh, and talk about a philanthropist! He was notorious for giving fresh leaves to those less-fortunate.
mccoyn is offline   QUOTE Thanks
Old 02-09-08, 04:39 PM   #2
seadave77

 
seadave77's Avatar 

Join Date: Jul 2002
Location: Newnan, GA

 
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.
seadave77 is offline   QUOTE Thanks
Old 02-09-08, 04:53 PM Thread Starter   #3
mccoyn
Senior Member

 
mccoyn's Avatar 

Join Date: Nov 2003
Location: Michigan, USA

 
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.

__________________
Once there was a caterpillar who had commas for legs. Which meant he had to allow a literary pause after each step. The other caterpillars really respected him for it and he came to have quite a commanding presence. Oh, and talk about a philanthropist! He was notorious for giving fresh leaves to those less-fortunate.
mccoyn is offline   QUOTE Thanks
Old 02-09-08, 07:34 PM   #4
seadave77

 
seadave77's Avatar 

Join Date: Jul 2002
Location: Newnan, GA

 
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.
seadave77 is offline   QUOTE Thanks
Old 02-09-08, 11:49 PM   #5
kayson
Member

 
kayson's Avatar 

Join Date: Jan 2005
Location: USA

 
Quote:
Originally Posted by seadave77 View Post
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

__________________
Project Silver
Intel Core i7-4770k
Asus Maximus VI Hero
G.Skill Sniper 2x4GB DDR3-1866
EVGA nVidia GeForce GTX 760
Corsair HX850
Samsung 840 Pro 256GB
Thermalright Venomous X || 2x 120mm Panaflo || Arctic Silver V
Lian-Li PC-A77FA || Vantec Nexus Fan Controller
(Build Journal)
Heatware
kayson is offline   QUOTE Thanks
Old 02-10-08, 08:20 PM   #6
seadave77

 
seadave77's Avatar 

Join Date: Jul 2002
Location: Newnan, GA

 
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.
seadave77 is offline   QUOTE Thanks

Post Reply New Thread Subscribe


Overclockers Forums > Software > Programming Tips and Tricks
Programming Tips and Tricks
Forum Jump

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Mobile Skin
All times are GMT -5. The time now is 06:30 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
You can add these icons by updating your profile information to include your Heatware ID, Benching Profile ID or your Folding/SETI profile ID. Edit your profile!
X

Welcome to Overclockers.com

Create your username to jump into the discussion!

New members like you have made this the best community on the Internet since 1998!


(4 digit year)

Why Join Us?

  • Share experience
  • Max out your hardware
  • Best forum members anywhere
  • Customized forum experience

Already a member?