Exemplo n.º 1
0
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************/
//require the auth class
require_once 'auth.php';
//initialize a new PayPal Access instance
$ppaccess = new PayPalAccess();
//if the code parameter is available, the user has gone through the auth process
if (isset($_GET['code'])) {
    //make request to exchange code for an access token
    $token = $ppaccess->get_access_token();
    echo "<h1>Token</h1>";
    print_r($token);
    //use access token to get user profile
    $profile = $ppaccess->get_profile();
    echo "<h1>User Profile</h1>";
    print_r($profile);
    //make request to refresh an expired access token
    $refreshed = $ppaccess->refresh_access_token();
    echo "<h1>Refreshed Token</h1>";
    print_r($refreshed);
    //validate the id token and provide back validation object
<?php

include "paypal-auth.php";
//if the code parameter is available, the user has gone through the auth process
if (isset($_GET['code'])) {
    //initialize a new PayPal Access instance
    $ppaccess = new PayPalAccess();
    //make request to exchange code for an access token
    $token = $ppaccess->get_access_token();
    //echo "<h1>Token</h1>";
    //echo "<pre>" . print_r($token) . "</pre>";
    //use access token to get user profile
    $profile = $ppaccess->get_profile();
    //echo "<h1>User Profile</h1>";
    //print_r($profile);
    //echo $profile->name;
    //echo $profile->email;
    //echo "<script>window.top('http://php-ppbrasil.rhcloud.com/peixe/homelogado.php?nome=" . $profile->name . "&email=" . $profile->email . "');</script>";
}
?>
<script>
    var jan = window.opener.top;
    //alert(window.opener.location.href());
    jan.location.href='http://php-ppbrasil.rhcloud.com/peixe/homelogado.php?nome=<?php 
echo $profile->name;
?>
&email=<?php 
echo $profile->email;
?>
';
    window.close();