Avoid IDE warnings in a mixed PHP version project

This commit is contained in:
Synchro 2015-09-22 08:11:09 +02:00
parent b3677b9b17
commit d6d7a8d17c
1 changed files with 9 additions and 7 deletions

View File

@ -10,6 +10,7 @@
* If no refresh token is obtained when running this file, revoke access to your app * If no refresh token is obtained when running this file, revoke access to your app
* using link: https://accounts.google.com/b/0/IssuedAuthSubTokens and run the script again. * using link: https://accounts.google.com/b/0/IssuedAuthSubTokens and run the script again.
* This script requires PHP 5.4 or later * This script requires PHP 5.4 or later
* PHP Version 5.4
*/ */
require 'vendor/autoload.php'; require 'vendor/autoload.php';
@ -19,19 +20,20 @@ session_start();
//If this automatic URL doesn't work, set it yourself manually //If this automatic URL doesn't work, set it yourself manually
$redirectUri = isset($_SERVER['HTTPS']) ? 'https://' : 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; $redirectUri = isset($_SERVER['HTTPS']) ? 'https://' : 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
//$redirectUri = 'http://localhost/phpmailer/get_oauth_token.php'; //$redirectUri = 'http://localhost/phpmailer/get_oauth_token.php';
//These details obtained are by setting up app in Google developer console.
$clientId = 'RANDOMCHARS-----duv1n2.apps.googleusercontent.com'; $clientId = 'RANDOMCHARS-----duv1n2.apps.googleusercontent.com';
$clientSecret = 'RANDOMCHARS-----lGyjPcRtvP'; $clientSecret = 'RANDOMCHARS-----lGyjPcRtvP';
//All details obtained by setting up app in Google developer console.
//Set Redirect URI in Developer Console as [https/http]://<yourdomain>/<folder>/get_oauth_token.php //Set Redirect URI in Developer Console as [https/http]://<yourdomain>/<folder>/get_oauth_token.php
$provider = new League\OAuth2\Client\Provider\Google ( $provider = new League\OAuth2\Client\Provider\Google(
[ array(
'clientId' => $clientId, 'clientId' => $clientId,
'clientSecret' => $clientSecret, 'clientSecret' => $clientSecret,
'redirectUri' => $redirectUri, 'redirectUri' => $redirectUri,
'scopes' => ['https://mail.google.com/'], 'scopes' => array('https://mail.google.com/'),
'accessType' => 'offline' 'accessType' => 'offline'
] )
); );
if (!isset($_GET['code'])) { if (!isset($_GET['code'])) {
@ -49,9 +51,9 @@ if (!isset($_GET['code'])) {
// Try to get an access token (using the authorization code grant) // Try to get an access token (using the authorization code grant)
$token = $provider->getAccessToken( $token = $provider->getAccessToken(
'authorization_code', 'authorization_code',
[ array(
'code' => $_GET['code'] 'code' => $_GET['code']
] )
); );
// Use this to interact with an API on the users behalf // Use this to interact with an API on the users behalf
// echo $token->accessToken.'<br>'; // echo $token->accessToken.'<br>';