WeGame RSS Generator [w/Code] menu

Shout-Out

User Tag List

Results 1 to 1 of 1
  1. #1
    saintg's Avatar Site Donator
    Reputation
    9
    Join Date
    Sep 2006
    Posts
    32
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    WeGame RSS Generator [w/Code]

    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;}
    ?>
    Last edited by saintg; 01-15-2009 at 12:33 PM.

    WeGame RSS Generator [w/Code]

Similar Threads

  1. [Selling] #New Blizzardstore Method#Generate unfreeze codes etc like dem chineese#
    By ge.rt in forum World of Warcraft Buy Sell Trade
    Replies: 0
    Last Post: 12-12-2014, 03:15 PM
  2. Color Code Generator
    By Phygar in forum WoW EMU Programs
    Replies: 15
    Last Post: 01-30-2008, 04:45 AM
All times are GMT -5. The time now is 01:41 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search