コード例 #1
0
 * (Required) The request token from the response to RequestPermissions. 
 */
$request->token = $_REQUEST['Requesttoken'];
/*
 * (Required) The verification code returned in the redirect from PayPal to the return URL. 
 */
$request->verifier = $_REQUEST['Verifier'];
/*
 * 	 ## Creating service wrapper object
Creating service wrapper object to make API call and loading
Configuration::getAcctAndConfig() returns array that contains credential and config parameters
*/
$service = new PermissionsService(Configuration::getAcctAndConfig());
try {
    /* wrap API method calls on the service object with a try catch */
    $response = $service->GetAccessToken($request);
} catch (Exception $ex) {
    require 'Error.php';
    exit;
}
/* Display the API response back to the browser. */
$ack = strtoupper($response->responseEnvelope->ack);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
	<title>GetAccessToken - Response</title>
</head>

<body>
コード例 #2
0
 GetAccessTokenReceipt.php
 Called by GetAccessToken.php
 ********************************************/
$path = '../lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'services/Permissions/PermissionsService.php';
session_start();
try {
    $requestEnvelope = new RequestEnvelope();
    $requestEnvelope->errorLanguage = "en_US";
    $request = new GetAccessTokenRequest();
    $request->requestEnvelope = $requestEnvelope;
    $request->token = $_REQUEST['Requesttoken'];
    $request->verifier = $_REQUEST['Verifier'];
    $permissions = new PermissionsService('Permissions');
    $response = $permissions->GetAccessToken($request);
    /* Display the API response back to the browser.
    	 If the response from PayPal was a success, display the response parameters'
    	 If the response was an error, display the errors received using APIError.php.
    	 */
    $ack = strtoupper($response->responseEnvelope->ack);
    if ($ack != "SUCCESS") {
        $_SESSION['reshash'] = $response;
        $location = "APIError.php";
        header("Location: {$location}");
    }
} catch (Exception $ex) {
    throw new Exception('Error occurred in GetAccessTokenReceipt method');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">