API: GET PSN-ID by sessionId [stable] (v0.103)
Created by: PSNAPI.ORG: http://psnapi.org/ |
Sourced by |
Licence: GNU GPL v3 |
Last update: 2010-06-27 |
Source Codes
Introduction
Sony has an official 'External PSN Sign In' page.
You can set your own site as the returnURL by GET.
The site forwards to your site on a successfull sign in with a sessionId by GET.
But there is no official public API to convert the sessionId into a user specific value (like the PSN-ID).
This API here converts a valid sessionId into the proper PSN-ID.
So everyone is able to use the Playstation Network SignIn for their own sites.
Click here and sign in for a simple test.
Get the output
http://api.geekweb.org/psn/getid/out.php
with the following GET parameters:
-
(*) sessionId=[any sessionId]
http://api.geekweb.org/psn/getid/out.php?sessionId=[YourSessionId]
-
source=[us|eumypsn|euforums]
The api can get the proper PSN-ID by different sources.
Choose the once you want to get the PSN-ID from.
('us' is the default value)
Example1: http://api.geekweb.org/psn/getid/out.php?sessionId=[YourSessionId]&source=us
Example2: http://api.geekweb.org/psn/getid/out.php?sessionId=[YourSessionId]&source=eumypsn
Example3: http://api.geekweb.org/psn/getid/out.php?sessionId=[YourSessionId]&source=euforums
-
error=[0,1]
This parameter handles the PHP error outputs.
('0' is the default value.)
Example1: http://api.geekweb.org/psn/getid/out.php?sessionId=[YourSessionId]&error=0
(output no php errors by error_reporting(0);)
Example2: http://api.geekweb.org/psn/getid/out.php?sessionId=[YourSessionId]&error=1
(output all php errors by error_reporting(E_ALL);)
(*) => Mandatory parameters
A small example for using this API
If you want to use this function on your own site,
create a php file on your server and type in the following code:
<?
// Example for using the PSNAPI.ORG GetId API
$PSLogURL = "https://store.playstation.com/external/index.vm?returnURL=";
$ThisURL = "http://".$_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"];
function getpsnid($sessId) {
$sources = array("us","eumypsn","euforums"); $psnid = "0";
for ($i=0;isset($sources[$i]) && !isPsnIdValid($psnid);$i++) {
$url = "http://api.geekweb.org/psn/getid/out.php?sessionId=" . $sessId . "&source=" . $sources[$i];
$psnid = file_get_contents($url);
}
return $psnid;
}
function isPsnIdValid($psnid) {
$regex = '/([a-z].{2,15})/i';
preg_match_all($regex, $psnid, $newid, PREG_SET_ORDER);
if (isset($newid[0][1]) && $psnid == $newid[0][1]) { return true; }
return false;
}
if (isset($_GET['sessionId'])) {
// get the proper psnid by the given sessionId
$psnid = getpsnid($_GET['sessionId']);
// TODO: connect with your user management here
echo ("Hi, <b>" . $psnid . "</b> ...");
} else {
// forward to the official external psn sign in page
// with your page url as returnURL by GET
header ("Location: " . $PSLogURL . $ThisURL);
}
?>
Created by: PSNAPI.ORG: http://psnapi.org/ |
Sourced by |
Licence: GNU GPL v3 |
Last update: 2010-06-27 |
Source Codes