Ejemplo n.º 1
0
}
/*
 * (Required) Information common to each API operation, such as the language in which an error message is returned.
 */
$requestEnvelope = new RequestEnvelope("en_US");
$request = new RequestPermissionsRequest($scope, $returnURL);
$request->requestEnvelope = $requestEnvelope;
/*
 * 	 ## 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->RequestPermissions($request);
} catch (Exception $ex) {
    require 'Error.php';
    exit;
}
/* 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.
 */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<div id="request_form">
<h3>RequestPermissions - Response</h3>
<?php 
}
/*
 * (Required) Information common to each API operation, such as the language in which an error message is returned.
*/
$requestEnvelope = new RequestEnvelope();
$requestEnvelope->errorLanguage = "en_US";
$request = new RequestPermissionsRequest($scope, $returnURL);
$request->requestEnvelope = $requestEnvelope;
/*
 * 	 ## Creating service wrapper object
Creating service wrapper object to make API call and loading
Configuration::getAcctAndConfig() returns array that contains credential and config parameters
*/
$permissions = new PermissionsService(Configuration::getAcctAndConfig());
try {
    $response = $permissions->RequestPermissions($request);
} catch (Exception $ex) {
    require_once '../error.php';
    exit;
}
/* 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);
session_start();
if ($ack != "SUCCESS") {
    $_SESSION['reshash'] = $response;
    $location = "APIError.php";
    header("Location: {$location}");
}