Using http client to call wordpress posts

software development

#1

hmm. i use this on many other hosts and it works just fine, but for some reason (12 hours later and still no reply from dreamhost) it doesn’t work on dreamhost. details below, could really use someone’s input who’s familiar with dreamhost, as i’m new there.

www.njdha.org uses php templates to call posts and categories of posts generated by a wordpress install located in njdha.org/blog/. i call the posts/cats using the code below:

<?php ini_set (user_agent, "blah");ini_set (default_socket_timeout, "5"); error_reporting(0); $theurl="http://www.njdha.org/blog/category/join-njdha/"; $filestring=file_get_contents("$theurl"); echo "$filestring"; ?>

this doesn’t work. the equivalent in c-u-r-l doesn’t work and is not allowed on the server. fOPEN the same. and trying to include it using a simple php include doesn’t work either (as it shouldn’t, for security reasons).

i can browse any category or post in the WP install as in http://www.njdha.org/blog/category/join-njdha/ so i know the blog is up and working fine, as i can admin it as well.

this appears to be a security issue on dreamhost’s end, and i need to resolve this right away, or pull the site and move it to another host. you can see an example of this working on another host at http://njdha.junkdesign.co.uk.

i chose dreamhost based on the strength of an email i got back from them BEFORE i had the client open the account saying my method for calling posts would work on their servers. it doesn’t.

any ideas?? they aren’t replying, and i’ve been ever so polite :slight_smile:

Best,

  • Rob

#2

i’ll add that i was forced to use iframes for now as the site had to go live this morning for the client. but that won’t work due to SEO plus it’s just a crap way of doing it.


#3

[quote]$theurl=“http://www.njdha.org/blog/category/join-njdha/”;
$filestring=file_get_contents("$theurl");[/url]The reason that will not work is because (per the PHP manual regarding file_get_contents):

“A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename and List of Supported Protocols/Wrappers for a list of supported URL protocols.”

DreamHost does not have fopen url wrappers enabled (as it shouldn’t, for security reasons). There is no reason why cURL should not work to retrieve that page (if it is programmed correctly) and cURL is indeed allowed on the server. :slight_smile:

–rlparker
–DreamHost Tech Support


#4

rlparker (and MikeM, who replied on the support panel).

THANK YOU. You are indeed correct (erm, as you prolly would be) that cURL does work. I didn’t know that fopen was disabled, and before I wrote in carping about this I had tried a previous call using cURL, but it didn’t work. could be because it was something i’d used on a different host with a differrent config, or just that i messed it up :stuck_out_tongue:

MikeM sent me this link - http://wiki.dreamhost.com/CURL - and voila, problem solved. Thank you both for your help, now I can get moving and get rid of those iframes (shudder).