psn_request.js
function GetUserData(callback)
	{
		Log("Fetching user profile data");

		// get the current user's data
		parent.Get("https://vl.api.np.km.playstation.net/vl/api/v1/mobile/users/me/info", {}, function(error, data)
		{
			if (error)
			{
				Log("Error fetching user profile: " + error);
				if (callback) callback("Error fetching user profile: " + error);
				return;
			}

			if (!data.onlineId)
			{
				Log("Missing PSNId from profile result: " + JSON.stringify(data, null, 2));
				if (callback) callback("Missing PSNId from profile result: " + JSON.stringify(data, null, 2));
				return;
			}

			// store user ID
			Log("We're logged in as " + data.onlineId);
			auth_obj.username = data.onlineId;
			// store user's region too
			auth_obj.region = 	data.region;

			// save updated data object
			DoSave(function()
				{
					// return no error
					if (callback) callback(false);
				}
			);
			// supply self to let API know we are a token fetch function
		}, GetUserData);
	}
function GetUserData(callback)
	{
		Log("Fetching user profile data");

		// get the current user's data
		parent.Get("https://vl.api.np.km.playstation.net/vl/api/v1/mobile/users/me/info", {}, function(error, data)
		{
			if (error)
			{
				Log("Error fetching user profile: " + error);
				if (callback) callback("Error fetching user profile: " + error);
				return;
			}

			if (!data.onlineId)
			{
				Log("Missing PSNId from profile result: " + JSON.stringify(data, null, 2));
				if (callback) callback("Missing PSNId from profile result: " + JSON.stringify(data, null, 2));
				return;
			}

			// store user ID
			Log("We're logged in as " + data.onlineId);
			auth_obj.username = data.onlineId;
			// store user's region too
			auth_obj.region = 	data.region;

			// save updated data object
			DoSave(function()
				{
					// return no error
					if (callback) callback(false);
				}
			);
			// supply self to let API know we are a token fetch function
		}, GetUserData);
	}
function GetUserData ( callback ) { Log ( "Fetching user profile data" ) ; // get the current user's data parent . Get ( "https://vl.api.np.km.playstation.net/vl/api/v1/mobile/users/me/info" , { } , function ( error , data ) { if ( error ) { Log ( "Error fetching user profile: " + error ) ; if ( callback ) callback ( "Error fetching user profile: " + error ) ; return ; } if ( ! data . onlineId ) { Log ( "Missing PSNId from profile result: " + JSON . stringify ( data , null , 2 ) ) ; if ( callback ) callback ( "Missing PSNId from profile result: " + JSON . stringify ( data , null , 2 ) ) ; return ; } // store user ID Log ( "We're logged in as " + data . onlineId ) ; auth_obj . username = data . onlineId ; // store user's region too auth_obj . region = data . region ; // save updated data object DoSave ( function ( ) { // return no error if ( callback ) callback ( false ) ; } ) ; // supply self to let API know we are a token fetch function } , GetUserData ) ; }
Fetch the user's profile data
Fetch the user s profile data