I'm writing a quick little script to grab some information from Stickam.com, specifically using the "API" they have set up to get a user id from a provided username, and a username from a provided userid. These are both publically accessible pieces of information, so I'm not getting into anything I shouldn't, I'm just using the publically accessible API instead of scraping the HTML.
For some reason I can't explain though, I can't seem to get the contents of the page using PHP. Here's my code:
But everytime I load this page on my server, I get this response:
Warning: file_get_conten ts(http://www.stickam.com/servlet/ajax/getLiveUser?una me=[username]) [function.file-get-contents]: failed to open stream: Connection timed out in [file] on line 7
I can load it just fine on my Apache server running on my personal computer, and I can load it in my browser (both IE9 and Firefox), but not on my website. I've tried mimicking the headers that my browser sends and creating a stream context to send with the file_get_conten ts() call, but so far nothing seems to work.
Any ideas?
For some reason I can't explain though, I can't seem to get the contents of the page using PHP. Here's my code:
Code:
$username = @$_GET['username'];
if(!$username) {
die("no username");
}
$url = "http://www.stickam.com/servlet/ajax/getLiveUser?uname=".$username;
$html = file_get_contents($url, false, $context);
echo "<pre>";
echo $html;
echo "</pre>";
Warning: file_get_conten ts(http://www.stickam.com/servlet/ajax/getLiveUser?una me=[username]) [function.file-get-contents]: failed to open stream: Connection timed out in [file] on line 7
I can load it just fine on my Apache server running on my personal computer, and I can load it in my browser (both IE9 and Firefox), but not on my website. I've tried mimicking the headers that my browser sends and creating a stream context to send with the file_get_conten ts() call, but so far nothing seems to work.
Any ideas?
Comment