vhin0210/php-psnpublictrophies

此包最新版本(1.1.5)没有提供许可证信息。

PHP库,通过PSN ID获取PSN公开奖杯

1.1.5 2018-10-19 04:34 UTC

This package is not auto-updated.

Last update: 2024-09-29 02:58:43 UTC


README

这是一个简单的PHP库,可以通过PSN ID获取PSN个人资料和奖杯。

注意:您的PSN账户必须启用双步验证

通过Composer安装

composer require vhin0210/php-psnpublictrophies

如何使用

获取访问令牌

$psnAuth = new \PSNPublicTrophiesLib\PSNPublicTrophiesAuth();

// Get Ticket UUID from Playstation Network by loging in to Playstation Network (works best with 2-Step Verification)
// Get the login URL. Copy the URL and open in a new tab
// Login and copy the whole URL. Your PSN account must have 2-Step Verification enabled, don't enter the Verification Code on that PS form.
$authUrl = $psnAuth->getAuthenticateUrl();

// Get Ticket UUID from the URL you copied.
$auth_url_parameters = $psnAuth->getAuthenticateUrlParameters($ticket_uuid_url);
$ticket_uuid = NULL;
if (isset($auth_url_parameters['ticket_uuid'])) {
  $ticket_uuid = $auth_url_parameters['ticket_uuid'];
}

// Authenticate with all the credentials
// $psn_id - your PSN ID
// $password - your password
// $ticket_uuid - the ticket uuid from the url you copied from playstation network
// $verification_code - code from the SMS you get from Playstation
$auth = $psnAuth->authenticate($psn_id, $password, $ticket_uuid, $verification_code);

// Get the access token (array). You can save this token in your database
$psn_account_token = $auth->GetTokens();

刷新令牌

// Initialize the library with the access token. This will automatically refresh the token.
// $psn_account_token - the access token (array)
$psnAuth = new \PSNPublicTrophiesLib\PSNPublicTrophiesAuth($psn_account_token);

// Get the new access token
$psn_account_token = $psnAuth->access_token;

获取个人资料

$psnAuth = new \PSNPublicTrophiesLib\PSNPublicTrophiesAuth($psn_account_token);

$profileData = $psnAuth->getProfile();