adamci24 Posted August 5, 2015 Share Posted August 5, 2015 Hi everyone. First post here, hopefully someone can help me out. I am trying to get live NFL scores in the form of an updated RSS feed to send to an LED scrolling sign for my man cave. I have researched this extensively and have found a PHP script that someone wrote that is suppose to pull the scores. The link to the original post is here: http://forum.xda-developers.com/showthread.php?t=272354&page=1 The link that this PHP script scrapes all the data from is: http://sports.espn.go.com/nfl/bottomline/scores If you click the espn link, you can see that it displays data that this PHP script is suppose to parse. Right now it just has an upcoming game on Sunday listed (PIT vs MIN). I put the nfl.php file on my web server and am getting a 404 error when trying to view it in safari. In chrome I see a document tree showing all the ECHO values in the PHP script, in the form of XML/RSS. I guess I'm trying to figure out what I doing wrong when it comes to viewing the output data in an actual RSS feed? The code written below clearly shows echo of data in the form of XML/RSS, so how do I get this into a working RSS feed for my led sign? Is there suppose to be an XML file assoiated? Here is the PHP code: <? function get_content($url) { $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_HEADER, 0); ob_start(); curl_exec ($ch); curl_close ($ch); $string = ob_get_contents(); ob_end_clean(); return $string; } header("Content-Type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n"; echo "<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\"\n"; echo " \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n\n"; echo "<rss version=\"0.91\">\n\n"; echo "<channel>\n"; echo "<title>NFL Scores</title>\n"; echo "<link>http://www.nfl.com/</link>\n"; echo "<description>NFL Scores</description>\n"; echo "<language>en-us</language>\n"; echo "<image>\n"; echo " <title>NFL Scores</title>\n"; echo " <url>http://www.mpiii.com/scores/nfl.gif</url>\n"; echo " <link>http://www.nfl.com</link>\n"; echo "</image>\n"; echo "<webMaster>info@nfl.com</webMaster>\n"; $content = get_content ("http://sports.espn.go.com/nfl/bottomline/scores"); $content_array=explode("&", $content); $scorearray = array(); $i=0; foreach($content_array as $content) { if (strpos($content, "_left")) { $equalpos = strpos($content, "="); $end = strlen($content); $title = substr($content, ($equalpos+1), $end); $title = str_replace("^", "", $title); $title = str_replace("%20", " ", $title); $scorearray[$i]["title"] = $title; } if (strpos($content, "_url")) { $equalpos = strpos($content, "="); $end = strlen($content); $url = substr($content, ($equalpos+1), $end); $url = str_replace("^", "", $url); $url = str_replace("%20", " ", $url); $scorearray[$i]["url"] = $url; $i++; } } foreach($scorearray as $score) { echo "<item>\n"; echo "<title>".$score["title"]."</title>\n"; echo "<link>".$score["url"]."</link>\n"; echo "</item>\n"; } echo "</channel>\n"; echo "</rss>\n"; ?> Quote Link to comment Share on other sites More sharing options...
requinix Posted August 5, 2015 Share Posted August 5, 2015 First, get rid of all that crazy parsing stuff you have there and just use parse_str. You'll end up with an array that looks like array( "nfl_s_delay" => "120", "nfl_s_stamp" => "0805040635", "nfl_s_left1" => "Minnesota at Pittsburgh (8:00 PM ET)", "nfl_s_right1_count" => "0", "nfl_s_url1" => "http://sports.espn.go.com/nfl/preview?gameId=400761517", "nfl_s_count" => "1", "nfl_s_loaded" => "true" )Are you saying your problem is that you're seeing PHP code instead of XML? Or, exactly what are you seeing? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.