I'm not sure about you, but our guild loves WeGame. Mostly because our work's security hasn't blocked it yet, and its a nicely setup site. The problem with WeGame is the lack of an RSS feed. With that, you could quickly see the updates, and if you're a geek web developer like me, integrate the latest, most popular, etc videos into a slice on your guild's home portal (which I'm about to do). I have a hard time finding exploits and am not the top notch at writing WoW guides, and so I'll support this site where I can.
To the point, I wrote a quick parser (62 lines) that generates an RSS feed for WeGame in the WoW area (code below). You could easily expand/redirect this to handle any/all of the games they offer, by changing the urls around. Also, note that I'm pretty new to PHP, and so if there is a better way to do something, let me know please
Example: WeGame Feed - popular
Code:
<?
session_start();
set_time_limit(10);
header("Content-Type: application/rss+xml");
(isset($_GET['sort'])) ? $sort = $_GET['sort'] : $sort = 'recent';
$weGame = array( 'popular' => array( 'url' => 'http://www.wegame.com/videos/browse/games/wow/?sort=popular', 'html' => null, 'text'=> null),
'recent' => array( 'url' => 'http://www.wegame.com/videos/browse/games/wow/?sort=recent', 'html' => null, 'text' => null),
'discussed' => array( 'url' => 'http://www.wegame.com/videos/browse/games/wow/?sort=comments','html' => null, 'text' => null),
'liked' => array( 'url' => 'http://www.wegame.com/videos/browse/games/wow/?sort=likes', 'html' => null, 'text' => null));
if($sort == 'popular' || $sort == 'recent' || $sort == 'discussed' || $sort == 'liked') {
getWeGameText($sort);
printWeGame($sort);
} else {
echo 'Invalid Option(s)<br />';
}
function getWeGameText($type) {
GLOBAL $weGame;
if(!getWeGameHTML($type))
return null;
// WeGame Videos Parse Columns:
// link, img, name, likes, views, added, desc, desc2
if($type == 'popular' || $type == 'discussed' || $type == 'liked')
preg_match_all('/<li class="item clearfix">\s*.*href="(?<link>.*)" .*\s*.*\s*<img src="(?<img>.*)" alt=.*\s*.*\s*.*\s*<h3><a.*">(?<name>.*)<\/a>.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*<span><strong>(?<likes>\d*).*\s*<span><strong>(?<views>\d*).*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*<span>(?<added>.*)<\/span>.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*href.*">(?<desc>.*)<\/a>.*\s*<p.*">(?<desc2>(.|\s)[^<]*)<\/p>/i', $weGame[$type]['html'], $weGame[$type]['text'], PREG_SET_ORDER);
else if($type == 'recent')
preg_match_all('/<li class="item clearfix">\s*.*href="(?<link>.*)" .*\s*.*\s*<img src="(?<img>.*)" alt=.*\s*.*\s*.*\s*<h3><a.*">(?<name>.*)<\/a>.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*<span><strong>(?<likes>\d*).*\s*<span><strong>(?<views>\d*).*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*<span>(?<added>.*)<\/span>.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*<\w.[^>]*\W(?<desc>.[^<]*).*\s*<\w.[^>]*\W(?<desc2>(.|\s)[^<]*)/i', $weGame[$type]['html'], $weGame[$type]['text'], PREG_SET_ORDER);}
function getWeGameHTML($type) {
GLOBAL $weGame;
$rnd = '&r='.rand();
$weGame[$type]['html'] = null;
$weGame[$type]['html'] = file_get_contents($weGame[$type]['url'] . $rnd);
return true;}
function printWeGame($type) {
GLOBAL $weGame;
$baseWeGameUrl = 'http://www.wegame.com';
$html = '<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title>WeGame Feed - ' . $type . '</title>
<link>'.$weGame[$type]['url'].'</link>
<description>WeGame RSS Feed</description>
<language>English</language>';
foreach($weGame[$type]['text'] as $game) {
$html .= '<item>
<title>'.htmlspecialchars($game['name'], ENT_COMPAT).'</title>
<link>'.$baseWeGameUrl.$game['link'].'</link>
<description><![CDATA['.$game['desc'].'<br />'.$game['likes'].' likes / '.$game['views'].' views</a><br />'.htmlspecialchars($game['desc2'], ENT_COMPAT).']]></description>
<content:encoded><![CDATA[<div style="float:left"><a href="'.$baseWeGameUrl.$game['link'].'" target="_blank"><img src="'.$game['img'].'" alt="" width="138" border="0" /></a></div><a href="'.$baseWeGameUrl.$game['link'].'" target="_blank">'.$game['desc'].'<br />'.$game['likes'].' likes / '.$game['views'].' views</a><br />'.htmlspecialchars($game['desc2'], ENT_COMPAT).']]></content:encoded>
</item> ';
}
$html .= '</channel>
</rss>';
echo $html;}
?>