I'm brand spankin' new to php so forigve me if this is a stupid quesiton.
I am trying to pull up the results from another site (on a diff domain) so that I can use some of the data in my own page.
for some reason when I try this:
<?php
$html = implode('', file('http://www.mydomain.com'));
echo $html;
?>
I get an error message as follows:
Warning: file(http://www.mydomain.com): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in /home/usr/public_html/cfhttp.php on line 11
Warning: implode(): Bad arguments. in /home/usr/public_html/cfhttp.php on line 11
the weird thing is that it works for some domains like this:
<?php
$html = implode('', file('http://www.yahoo.com'));
echo $html;
?>
any suggestions?
thx,
Burr[/i]
file function not returning anything...
Moderator: General Moderators
Yeah My Guess
I'm guessing it has to do with the sites' CHMOD settings/ security settings.
file()
so is there another solution for this? Aside from file()? when I use the coldfusion equivalent (cfhttp) it works fine so I"m guessing that it's not a permissions issue on the web server.
any other ideas?
thx
Burr
any other ideas?
thx
Burr
- Michael 01
- Forum Commoner
- Posts: 87
- Joined: Wed Feb 04, 2004 12:26 am
Just a word of advice on this topic. What you are using, or trying to code is a "grabber" script which causes the poor bastard on the other end a ton of lost bandwidth. Most sites have .ht access points for images and content to stop bandwidth thieves. (not that you are one..just pointing this out is all)
There are several approved and very well equiped sites that allow such information transfer through routed protocols to all subscribers with any information that you could desire and sometimes even with the drop in code in tact. Everything from drop in Java snippets to hard coded CGI or PHP.
Many Nuke sites also provide such "modules" which keeps their community and others associated by these means connected and out in the open, and by doing so by these nice and "legal" methods, you can easily keep sites that dont like such intrusions from closing your site down, and keep the open source community in the public eye nice and legal like.

There are several approved and very well equiped sites that allow such information transfer through routed protocols to all subscribers with any information that you could desire and sometimes even with the drop in code in tact. Everything from drop in Java snippets to hard coded CGI or PHP.
Many Nuke sites also provide such "modules" which keeps their community and others associated by these means connected and out in the open, and by doing so by these nice and "legal" methods, you can easily keep sites that dont like such intrusions from closing your site down, and keep the open source community in the public eye nice and legal like.
lecture
Michael, thanks for the lecture, however both of the sites in question are both clients of mine.
As I said in my first post on this thread, I am new to PHP, but I am not new to web design/development and I use good ethics when developing sites.
since no one has provided me with a sufficient answer to this question, I'm guessing either 1) php can't do this as nicely as cold fusion can or 2) no one knows how to do this.
as a work around I've created at cfhttp page that pulls the results that I need and I'm using file() to hit the cf server and that page. This is a hack job work around though as I'm having to go from 1 server, to another, then back to the first to get the results I want.
certainly there has to be a better way....
any other suggestions?
thx,
Burr
As I said in my first post on this thread, I am new to PHP, but I am not new to web design/development and I use good ethics when developing sites.
since no one has provided me with a sufficient answer to this question, I'm guessing either 1) php can't do this as nicely as cold fusion can or 2) no one knows how to do this.
as a work around I've created at cfhttp page that pulls the results that I need and I'm using file() to hit the cf server and that page. This is a hack job work around though as I'm having to go from 1 server, to another, then back to the first to get the results I want.
certainly there has to be a better way....
any other suggestions?
thx,
Burr
figured it out
I figured this out here's what I did:
<?php
$request = "GET / HTTP/1.1\r\nHOST: http://www.mydomain.com\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204\r\nAccept: text/xml,application/xml,application/xhtml+xml,'text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1\r\nAccept-Language: en-us, en;q=0.50\r\nAccept-Encoding: gzip, deflate, compress;q=0.9\r\nAccept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66\r\nKeep-Alive: 300\r\nConnection: keep-alive\r\nReferer: http://www.myreferer.com\r\nCache-Control: max-h=0\r\n\r\n";
$socket= fsockopen("www.mydomain.com", 80);
fputs($socket, $request);
$ret = '';
while ( !feof( $socket ) ) {
$ret .= fgets( $socket, 4096 );
}
echo $ret;
?>
Burr
<?php
$request = "GET / HTTP/1.1\r\nHOST: http://www.mydomain.com\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204\r\nAccept: text/xml,application/xml,application/xhtml+xml,'text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1\r\nAccept-Language: en-us, en;q=0.50\r\nAccept-Encoding: gzip, deflate, compress;q=0.9\r\nAccept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66\r\nKeep-Alive: 300\r\nConnection: keep-alive\r\nReferer: http://www.myreferer.com\r\nCache-Control: max-h=0\r\n\r\n";
$socket= fsockopen("www.mydomain.com", 80);
fputs($socket, $request);
$ret = '';
while ( !feof( $socket ) ) {
$ret .= fgets( $socket, 4096 );
}
echo $ret;
?>
Burr