Hi,
What I want to do is connect to xbox.com, a website that is nothing to do with me, and display on my clan's website whether or not a user is connected to Xbox Live.
I have modified a bit of code I found on the web which would connect to http://live.xbox.com/en-GB/profile/profile.aspx?GamerTag=Andz and display the word "Online" or "Offline" depending on whether the user is online or offline. However, the error_log created in the directory the script is contains this:
[30-Dec-2005 03:59:15] PHP Warning: fopen(): HTTP request failed! in /home/dropshoc/public_html/helljumpers/meres_testing_ground/online_test.php on line 2
[30-Dec-2005 03:59:15] PHP Warning: fopen(http://live.xbox.com/en-GB/profile/profile.aspx?pp=0&GamerTag=): failed to open stream: Connection reset by peer in /home/dropshoc/public_html/helljumpers/meres_testing_ground/online_test.php on line 2
[30-Dec-2005 04:00:13] PHP Warning: fopen(): HTTP request failed! in /home/dropshoc/public_html/helljumpers/meres_testing_ground/online_test.php on line 2
[30-Dec-2005 04:00:13] PHP Warning: fopen(http://live.xbox.com/en-GB/profile/profile.aspx?pp=0&GamerTag=): failed to open stream: Connection reset by peer in /home/dropshoc/public_html/helljumpers/meres_testing_ground/online_test.php on line 2
[30-Dec-2005 04:00:17] PHP Warning: fopen(): HTTP request failed! in /home/dropshoc/public_html/helljumpers/meres_testing_ground/online_test.php on line 2
[30-Dec-2005 04:00:17] PHP Warning: fopen(http://live.xbox.com/en-GB/profile/profile.aspx?pp=0&GamerTag=): failed to open stream: Connection reset by peer in /home/dropshoc/public_html/helljumpers/meres_testing_ground/online_test.php on line 2
[30-Dec-2005 04:00:50] PHP Warning: fopen(): HTTP request failed! in /home/dropshoc/public_html/helljumpers/meres_testing_ground/online_test.php on line 2
[30-Dec-2005 04:00:50] PHP Warning: fopen(http://live.xbox.com/en-GB/profile/profile.aspx?pp=0&GamerTag=): failed to open stream: Connection reset by peer in /home/dropshoc/public_html/helljumpers/meres_testing_ground/online_test.php on line 2
[30-Dec-2005 04:01:49] PHP Warning: fopen(): HTTP request failed! in /home/dropshoc/public_html/helljumpers/meres_testing_ground/online_test.php on line 2
[30-Dec-2005 04:01:49] PHP Warning: fopen(http://live.xbox.com/en-GB/profile/profile.aspx?pp=0&GamerTag=Andz): failed to open stream: Connection reset by peer in /home/dropshoc/public_html/helljumpers/meres_testing_ground/online_test.php on line 2
[30-Dec-2005 04:03:43] PHP Warning: fopen(): HTTP request failed! in /home/dropshoc/public_html/helljumpers/meres_testing_ground/online_test.php on line 2
[30-Dec-2005 04:03:43] PHP Warning: fopen(http://live.xbox.com/en-GB/profile/profile.aspx?pp=0&GamerTag=Andz): failed to open stream: Connection reset by peer in /home/dropshoc/public_html/helljumpers/meres_testing_ground/online_test.php on line 2
[30-Dec-2005 05:37:47] PHP Warning: fopen(): HTTP request failed! in /home/dropshoc/public_html/helljumpers/meres_testing_ground/online_test.php on line 13
[30-Dec-2005 05:37:47] PHP Warning: fopen(http://live.xbox.com/en-GB/profile/profile.aspx?pp=0&GamerTag=Andz): failed to open stream: Connection reset by peer in /home/dropshoc/public_html/helljumpers/meres_testing_ground/online_test.php on line 13
[30-Dec-2005 05:37:47] PHP Warning: feof(): supplied argument is not a valid stream resource in /home/dropshoc/public_html/helljumpers/meres_testing_ground/online_test.php on line 15
[30-Dec-2005 05:37:47] PHP Warning: fread(): supplied argument is not a valid stream resource in /home/dropshoc/public_html/helljumpers/meres_testing_ground/online_test.php on line 16
Here is the link to the script:
http://helljumpers.bungie.org/meres_testing_ground/online_test.php
And here is the code:
<?php
$grab_url="http://live.xbox.com/en-GB/profile/profile.aspx?GamerTag=Andz";
$start_grab = "Current Status:"; // where to start
$stop_grab = "</span></p></div>"; // Where to end content grab
$getdata=@fread(@fopen("$grab_url", "r"), 4096);
if ($getdata) {
$starting = strpos($getdata, "$start_grab");
$finishing = strpos($getdata, "$stop_grab");
$my_range = $finishing-$starting;
$content=Substr($getdata, $starting, $my_range);
$text = str_replace($content, "'","& #39;'");// remove all apostrophies
$text = preg_replace('/</',' <',$content);
$text = preg_replace('/>/','> ',$text);
$desc = html_entity_decode(strip_tags($text));
$desc = preg_replace('/[\n\r\t]/',' ',$desc);
$desc = preg_replace('/ /',' ',$desc);
$desc = rtrim($desc);
}
else { $content = "No data at this moment.";}
echo $content;
?>
The link to xbox.com I provided is a page that shows if a particular user is connected to xbox live rather than an actual website.
I would love it if someone could help me 🙂