например, жму на кнопку- войти, появляется форма ввода от плейстейшен (email и pass) , жду ОК . и меня переносит на пустую страницу, где пишется- Hi, мой ник нейм, а в строке браузера, выдается ID
Я так понял, этот самый ID содержится в переменной $psnid
Так вот, как этот id сохранить в мою базу данных?
<?
// 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);
}
?>
|