Results 1 to 6 of 6
  1. #1
    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.

  2. #2
    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.

  3. #3
    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.

  4. #4
    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.

  5. #5
    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 (4.3GHz @ 1.265V)
    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

  6. #6
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •