API Help! :) - PlanetSide Universe
PSU Social Facebook Twitter Twitter YouTube Steam TwitchTV
PlanetSide Universe
PSU: May I salvage your earwax?
Home Forum Chat Wiki Social AGN PS2 Stats
Notices
Go Back   PlanetSide Universe > PlanetSide Discussions > PlanetSide 2 API Discussion

 
 
Thread Tools Search this Thread Display Modes
Old 2013-03-05, 02:27 AM   [Ignore Me] #1
SecretSquirrel
Private
 
API Help! :)


hey all I am new to using APIs and was wondering if anybody could give a lowly peon like myself a helping hand


Thanks !
SecretSquirrel is offline  
Old 2013-03-05, 08:16 AM   [Ignore Me] #2
Goblinhunter
Private
 
Re: API Help! :)


Happy to help, but we are going to need more details on what areas you are having issues with so we can give specific help. Have you been through all teh details on http://census.soe.com/?
__________________
outfitpoints.com - the Planetside 2 Outfit Management Toolkit
Goblinhunter is offline  
Old 2013-03-05, 09:44 AM   [Ignore Me] #3
Hamma
PSU Admin
 
Hamma's Avatar
 
Re: API Help! :)


Also check out our initial Wiki page on the API:

http://wiki.planetside-universe.com/ps/API

Otherwise as mentioned we will need more info on what you are trying to do.
__________________

PlanetSide Universe - Administrator / Site Owner - Contact @ PSU
Hamma Time - Evil Ranting Admin - DragonWolves - Commanding Officer
Hamma is offline  
Old 2013-03-05, 01:47 PM   [Ignore Me] #4
Dreadnaut
Contributor
Private
 
Re: API Help! :)


What ^^ guys said

I know, I'm a giver.
__________________
Dreadnaut is offline  
Old 2013-03-08, 04:16 AM   [Ignore Me] #5
SecretSquirrel
Private
 
Re: API Help! :)


I went through the information that you all provded I never knew about he PSU wiki thanks for that

one question i Have is how do I extract information from this link in php @_@

http://census.soe.com/get/ps2-beta/o..._online_status

that was pulled from the census.seo.com example url
SecretSquirrel is offline  
Old 2013-03-08, 12:28 PM   [Ignore Me] #6
Ghryphen
PSU Code Monkey
 
Ghryphen's Avatar
 


Originally Posted by SecretSquirrel View Post
I went through the information that you all provded I never knew about he PSU wiki thanks for that

one question i Have is how do I extract information from this link in php @_@

http://census.soe.com/get/ps2-beta/o..._online_status

that was pulled from the census.seo.com example url
Use file_get_contents() or cURL to fetch the url, then use decode_json() to convert the string into a data object. See php.net for some details and examples for those functions.
__________________

Twitter | Dragon Wolves
Ghryphen is offline  
Old 2013-03-10, 12:08 AM   [Ignore Me] #7
Dreadnaut
Contributor
Private
 
Re: API Help! :)


Originally Posted by Gryphon View Post
Use file_get_contents() or cURL to fetch the url, then use decode_json() to convert the string into a data object. See php.net for some details and examples for those functions.
Exactly that, Eg:
Code:
<?php
     error_reporting(E_ALL);
     ini_set('display_errors', 1);

     $folder = "ps2-beta";
     $outfit_alias = "666";

     $member_status = json_decode(file_get_contents("http://census.soe.com/get/$folder/outfit?alias=$outfit_alias&c:resolve=member_online_status"));
?>
Then just loop through $member_status however you want and pull the info you need.

Hope that helps.
__________________
Dreadnaut is offline  
Old 2013-03-10, 12:59 AM   [Ignore Me] #8
SecretSquirrel
Private
 
Re: API Help! :)


I found the info in the PSU Wiki!

I wish this api had SOME sort of API docs

thanks for all the useful help! =d

Last edited by SecretSquirrel; 2013-03-10 at 06:03 AM.
SecretSquirrel is offline  
Old 2013-03-10, 10:39 PM   [Ignore Me] #9
SecretSquirrel
Private
 
Re: API Help! :)


I am having an issue with this piece of code its not showing up for anybody but locally it works and outputs the information anybody have any ideas? thanks!

Code:
$character = $_POST["character"];
		$submit    = $_POST["submit"];

		if (isset($submit)) {
			$ApiLink     = "https://census.soe.com/get/ps2-beta/character/?name.first_lower=^" . $character . "&c:limit=1000&c:show=name.first&c:show=id&c:show=type.faction";
			$json_decode = (json_decode(file_get_contents($ApiLink), true));
			$output      = $json_decode["character_list"];

			foreach ($output as $key=> $value) {
				$get_character[$key]    = $output[$key]["name"];
				$get_character_id[$key] = $output[$key]["id"];
				echo $get_character[$key]["first"] . "<br/>";
				echo "it worked you submited " . $character;

			}
		}
		else {
			?>
        <form action="search.php" method="POST">
            <input type="text" name="character" autofocus required>
            <input name="submit" type="submit" value="Find me!">
        </form>
		<?php
		}
SecretSquirrel is offline  
Old 2013-03-11, 03:12 PM   [Ignore Me] #10
Ghryphen
PSU Code Monkey
 
Ghryphen's Avatar
 
Re: API Help! :)


It works for me, are you using CaSe in your search that isn't working? Should probably change to strtolower($_POST["character"]) to ensure you are searching with lower.

FYI, there is also a limit of 100 results.

http://www.planetside-universe.com/api/squirrel.php
http://www.planetside-universe.com/api/squirrel.phps
http://pside.co/YYv2nz
__________________

Twitter | Dragon Wolves

Last edited by Ghryphen; 2013-03-12 at 05:05 PM.
Ghryphen is offline  
Old 2013-03-13, 05:08 AM   [Ignore Me] #11
SecretSquirrel
Private
 
Re: API Help! :)


awesome thanks =b I got it to work it was the strtolwr

I am having errors with an outfit listing here is the code and error
Error
HTML Code:
Warning: Invalid argument supplied for foreach() in F:\web server\wamp\www\API\includes\functions-outfit.php on line 37
Call Stack
#	Time	Memory	Function	Location
1	0.0002	249376	{main}( )	..\outfit.php:0
2	0.0021	527856	display_outfit_members( )	..\outfit.php:28
Code: The error is on the middle 3rd foreach ;( this only happens on certain outfits (666) for example
HTML Code:
		foreach ($output as $key => $value) {
			$alias***91;$key***93;   = $output***91;$key***93;***91;"alias"***93;;
			$name***91;$key***93;    = $output***91;$key***93;***91;"name"***93;;
			$members***91;$key***93; = $output***91;$key***93;***91;"members"***93;;

			foreach ($members***91;$key***93; as $row) {

				$name_user   = $row***91;'name'***93;***91;'first'***93;;
				$char_id     = $row***91;'character_id'***93;;
				$outfit_rank = $row***91;'rank'***93;;
				$experience  = $row***91;'experience'***93;;
				$kills       = $row***91;'stats'***93;***91;'kills'***93;***91;'value'***93;;
				$deaths      = $row***91;'stats'***93;***91;'deaths'***93;***91;'value'***93;;
				$kdr         = $row***91;'stats'***93;***91;'kill_death_ratio'***93;***91;'value'***93;;
				$fcc         = $row***91;'stats'***93;***91;'facility_capture_count'***93;***91;'value'***93;;
				$fdc         = $row***91;'stats'***93;***91;'facility_defended_count'***93;***91;'value'***93;;
				$medals      = $row***91;'stats'***93;***91;'medal_count'***93;***91;'value'***93;;

				echo "<tr>";
				echo "<td><a href='character.php?id=" . $char_id . "'>" . $name_user . "</a></td>";
				echo "<td>" . $outfit_rank . "</td>";
				foreach ($experience as $expier => $value) {
					echo "<td>" . $value***91;'rank'***93; . "</td>";
					echo "<td>" . $value***91;'score'***93; . "</td>";

				}
				echo "<td>" . $kills . "</td>";
				echo "<td>" . $deaths . "</td>";
				echo "<td>" . number_format($kdr, 3) . "</td>";
				echo "<td>" . $fcc . "</td>";
				echo "<td>" . $fdc . "</td>";
				echo "<td>" . $medals . "</td>";
				echo "</tr>";
			}
SecretSquirrel is offline  
Old 2013-03-17, 04:46 AM   [Ignore Me] #12
zomg
Staff Sergeant
 
zomg's Avatar
 
Re: API Help! :)


Just have it var_dump the variables when it gives you an error so you can check what's wrong. Most likely the cause is that the API decides to return data that doesn't happen to contain the values. Some rows it returns are incomplete, and thus if your code assumes certain keys exist, it won't work properly.


They really should fix the API so it returns nulls for data that's not in place since missing keys is definitely not the right way to go.
__________________
zomg is offline  
 
  PlanetSide Universe > PlanetSide Discussions > PlanetSide 2 API Discussion

Bookmarks

Tags
mar05tweet

Discord


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 02:23 AM.

Content © 2002-2013, PlanetSide-Universe.com, All rights reserved.
PlanetSide and the SOE logo are registered trademarks of Sony Online Entertainment Inc. © 2004 Sony Online Entertainment Inc. All rights reserved.
All other trademarks or tradenames are properties of their respective owners.
Powered by vBulletin
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.