Jump to content

ShoeLace1291

Members
  • Posts

    401
  • Joined

  • Last visited

Everything posted by ShoeLace1291

  1. I am trying to modify a class that I found that is a Steam API class. I want it to work with codeigniter. I keep getting call to a member function on a non-object error when I call the getProfileData function. Not sure why it's happening. Here is the code: The library: <?php // Disable XML warnings to avoid problems when SteamCommunity is down libxml_use_internal_errors(true); // Use SteamUtility to fetch URLs and other stuff require_once 'SteamUtility.php'; /** * SteamUser - Representation of any Steam user profile * * @category SteamAPI * @copyright Copyright (c) 2012 Matt Ryder (www.mattryder.co.uk) * @license GPLv2 License * @version v1.3 * @link https://github.com/MattRyder/SteamAPI/blob/master/steam/SteamUser.php * @since Class available since v1.0 */ class SteamUser { private $userID; private $vanityURL; private $apiKey; public $info; /** * Constructor * @param mixed $id User's steamID or vanityURL * @param string $apiKey API key for http://steamcommunity.com/dev/ */ /** * GetProfileData * - Accesses Steam Profile XML and parses the data */ function __construct($params){ $userId = $params['userId']; $this->CI =& get_instance(); $this->CI->load->config('steam'); if(empty($userId)) { echo "Error: No Steam ID or URL given!", PHP_EOL; return NULL; } if(is_numeric($userId)) { $this->userID = $userId; } else { $this->vanityURL = strtolower($userId); } $this->apiKey = $this->CI->config->item('api_key'); } function getProfileData() { $info = array(); //Set Base URL for the query: if(empty($this->vanityURL)) { $base = "http://steamcommunity.com/profiles/{$this->userId}/?xml=1"; } else { $base = "http://steamcommunity.com/id/{$this->vanityURL}/?xml=1"; } try { $content = SteamUtility::fetchURL($base); if ($content) { $parsedData = new SimpleXMLElement($content); } else { return null; } } catch (Exception $e) { //echo "Whoops! Something went wrong!\n\nException Info:\n" . $e . "\n\n"; return null; } if(!empty($parsedData)) { $info['steamID64'] = (string)$parsedData->steamID64; $info['steamID'] = (string)$parsedData->steamID; $info['stateMessage'] = (string)$parsedData->stateMessage; $info['visibilityState'] = (int)$parsedData->visibilityState; $info['privacyState'] = (string)$parsedData->privacyState; $info['avatarIcon'] = (string)$parsedData->avatarIcon; $info['avatarMedium'] = (string)$parsedData->avatarMedium; $info['avatarFull'] = (string)$parsedData->avatarFull; $info['vacBanned'] = (int)$parsedData->vacBanned; $info['tradeBanState'] = (string)$parsedData->tradeBanState; $info['isLimitedAccount'] = (string)$parsedData->isLimitedAccount; $info['onlineState'] = (string)$parsedData->onlineState; $info['inGameServerIP'] = (string)$parsedData->inGameServerIP; //If their account is public, get that info: if($info['privacyState'] == "public") { $info['customURL'] = (string)$parsedData->customURL; $info['memberSince'] = (string)$parsedData->memberSince; $info['steamRating'] = (float)$parsedData->steamRating; $info['hoursPlayed2Wk'] = (float)$parsedData->hoursPlayed2Wk; $info['headline'] = (string)$parsedData->headline; $info['location'] = (string)$parsedData->location; $info['realname'] = (string)$parsedData->realname; $info['summary'] = (string)$parsedData->summary; } //If they're in a game, grab that info: if($info['onlineState'] == "in-game") { $info['inGameInfo']['inGameInfo'] = array(); $info['inGameInfo']["gameName"] = (string)$parsedData->inGameInfo->gameName; $info['inGameInfo']["gameLink"] = (string)$parsedData->inGameInfo->gameLink; $info['inGameInfo']["gameIcon"] = (string)$parsedData->inGameInfo->gameIcon; $info['inGameInfo']["gameLogo"] = (string)$parsedData->inGameInfo->gameLogo; $info['inGameInfo']["gameLogoSmall"] = (string)$parsedData->inGameInfo->gameLogoSmall; } //Get their most played video games: if(!empty($parsedData->mostPlayedGames)) { $info['mostPlayedGames'] = array(); $i = 0; foreach ($parsedData->mostPlayedGames->mostPlayedGame as $mostPlayedGame) { $info['mostPlayedGames'][$i] = new stdClass(); $info['mostPlayedGames'][$i]['gameName'] = (string)$mostPlayedGame->gameName; $info['mostPlayedGames'][$i]['gameLink'] = (string)$mostPlayedGame->gameLink; $info['mostPlayedGames'][$i]['gameIcon'] = (string)$mostPlayedGame->gameIcon; $info['mostPlayedGames'][$i]['gameLogo'] = (string)$mostPlayedGame->gameLogo; $info['mostPlayedGames'][$i]['gameLogoSmall'] = (string)$mostPlayedGame->gameLogoSmall; $info['mostPlayedGames'][$i]['hoursPlayed'] = (string)$mostPlayedGame->hoursPlayed; $info['mostPlayedGames'][$i]['hoursOnRecord'] = (string)$mostPlayedGame->hoursOnRecord; $info['mostPlayedGames'][$i]['statsName'] = (string)$mostPlayedGame->statsName; $i++; } } //Any weblinks listed in their profile: if(!empty($parsedData->weblinks)) { $this['weblinks'] = array(); $i = 0; foreach ($parsedData->weblinks->weblink as $weblink) { $info['weblinks'][$i]['title'] = (string)$weblink->title; $info['weblinks'][$i]['link'] = (string)$weblink->link; $i++; } } //And grab any subscribed groups: if(!empty($parsedData->groups)) { $this->groups = array(); $i = 0; foreach ($parsedData->groups->group as $group) { $info['groups'][$i] = array(); $info['groups'][$i]['groupID64'] = (string)$group->groupID64; $info['groups'][$i]['groupName'] = (string)$group->groupName; $info['groups'][$i]['groupURL'] = (string)$group->groupURL; $info['groups'][$i]['headline'] = (string)$group->headline; $info['groups'][$i]['summary'] = (string)$group->summary; $info['groups'][$i]['avatarIcon'] = (string)$group->avatarIcon; $info['groups'][$i]['avatarMedium'] = (string)$group->avatarMedium; $info['groups'][$i]['avatarFull'] = (string)$group->avatarFull; $info['groups'][$i]['memberCount'] = (string)$group->memberCount; $info['groups'][$i]['membersInChat'] = (string)$group->membersInChat; $info['groups'][$i]['membersInGame'] = (string)$group->membersInGame; $info['groups'][$i]['membersOnline'] = (string)$group->membersOnline; $i++; } } } return $info; } The model where I call the library: function retrieve($member_id = 0, $page = 1, $limit = 10){ $info = array(); $this->db->select('memberId AS id, facebookId, steamId, userName, emailAddress, dateJoined, dateBorn') ->from('members') ->where('memberId', $member_id) ->limit(1); if($query = $this->db->get()){ if($query->num_rows() > 0){ $member = $query->row_array(); var_dump($member); $info = $member; if($member['steamId'] != ''){ $this->load->library('SteamUser', array('userId' => $member['steamId'])); $steam = $this->SteamUser->getProfileData(); $info['steam'] = array( 'id' => $member['steamId'], 'avatar' => $steam['avatarIcon'] ); } } } $this->info = $info; }
  2. I've been googling for about the last 3 hours now looking for a decent extension to CodeIgniter's template parser class that adds the use of conditional statements. I can't really seem to find anything. Would anybody have any suggestions of one that would help me do something like this: {if:is_admin} show an admin link {/if}
  3. I am in the process of developing my personal website. There will not be any member accounts, but I will still need to have an admin panel so that I can manage my content. I will be the only person using the admin panel. Without using a database table to store it, what would be the most secure way to store a single admin password that I can use to login to my admin panel?
  4. Here are several requests of mine... I think more people would find these tutorials to be useful. 1: Pretty URL's with URL Routing (Object Oriented) 2: Tag Clouds and Querying Similar Posts (Comma-Separated Values) 3: How to Write a Lightweight MVC I know there are a lot of these tutorials on the net, but the ones I've found either aren't formatted well, or are very hard to follow. I really prefer PHPFreaks tutorials over most other websites' tutorials. Just a few suggestions!
  5. Visual QuickStart Guide: JavaScript & Ajax by Tom Negrino and Dori Smith is pretty good. My college photoshop class used a PS book from the Visual QuickStart series
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.