Widescreen Gaming Forum

[-noun] Web community dedicated to ensuring PC games run properly on your tablet, netbook, personal computer, HDTV and multi-monitor gaming rig.
It is currently 01 May 2024, 16:22

All times are UTC [ DST ]




Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
PostPosted: 13 Jul 2013, 14:30 
Offline
User avatar

Joined: 27 Feb 2013, 16:25
Posts: 163
Location: Gloucester, UK
Okay so very new to Drupal and it's API so please forgive this very bad coding....
So the idea here is I have created a form SGC (Steam Game Compare) and it takes the Custom URL section of your steam profile.
This is then converted to a SteamID so my CustomURL is "LuckyNoS7evin" this is converted to 76561198040969636
It then goes to Steam and gets my games.
It then gets the WSGF games list (this is what I hope to replace with Drupal DB hooks at a later date)
It then goes through both lists and does some matching (very crude right now but want to improve this.

My questions is how do I get content onto the screen? I have no clue on how to get the data I have in the Form Submit into what ever I need to get it into. Any help will be great!

Code:
<?php
function sgc_menu() {
  $items = array();
  $items['examples/sgc'] = array(
    'title' => 'SGC Example',
    'page callback' => 'sgc_form',
    'access callback' => TRUE,
    'expanded' => TRUE,
  );
  return $items;
}

function sgc_form() {
  return drupal_get_form('sgc_my_form');
}

function sgc_my_form($form_state) {
  $form['sgc_customURL'] = array(
    '#type' => 'textfield',
    '#title' => "Custom URL",
    '#description' => "http://steamcommunity.com/id/{CustomURL}/",
  ); 
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
  );
  return $form;
}

function sgc_my_form_validate($form, &$form_state) {

}

function sgc_my_form_submit($form, &$form_state) {
   $userProfileURL = "http://steamcommunity.com/id/" . $form_state['values']['sgc_customURL'] . "/?xml=1";
   $userProfileXML = simplexml_load_file($userProfileURL);
   $steamID64 = (string)$userProfileXML->steamID64;

   $urlSteam = "http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key={MyKeyRemoved}&steamid=" . $steamID64 . "&format=xml&include_appinfo=1";
   $urlWSGF = "http://www.wsgf.org/mgl/xml-all";

   $xmlSteam = simplexml_load_file($urlSteam);
   $xmlWSGF = simplexml_load_file($urlWSGF);

   $unmatchedGames = array();
   $xmlMatched = array();
   foreach ($xmlWSGF->node as $gameWSGF) {
      $steamID = (int)$gameWSGF->SteamID;

      if($steamID > 0 ) {
         $xpath="/response/games/message[appid=".$steamID."]";
            $result = $xmlSteam->xpath($xpath);

         if(count($result) > 0) {
            while(list( , $game) = each($result)) {
               $xmlMatched[]= $gameWSGF;
            }
         }
         else {
            array_push($unmatchedGames, $gameWSGF);      
         }
      }
      else {
         array_push($unmatchedGames, $gameWSGF);
      }
   }
}
?>


@Brett - I know I'm matching on steam ID from the whole games list but at some future point it may actually be wise to have two different DB calls, one to get all games with SteamIDs and one to get all games without SteamIDs... This may make my job and your job easier.

_________________
i7 3770K (Ivy bridge) | Corsair Dominator 32GB | Asus P8Z77-V LE Plus Intel Z77 | Corsair H100i | 2 x Gigabyte ATi Radeon HD 7950 in crossfire | NXZT Phantom case | OCZ 1000W Powersupply | Samsung 840 PRO 256GB | 2x OCZ agility 3 60GB SSDs | 2x 1TB HDDs |


Top
 Profile  
 


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  




Powered by phpBB® Forum Software © phpBB Group