本文整理汇总了PHP中apiClient::setScopes方法的典型用法代码示例。如果您正苦于以下问题:PHP apiClient::setScopes方法的具体用法?PHP apiClient::setScopes怎么用?PHP apiClient::setScopes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apiClient
的用法示例。
在下文中一共展示了apiClient::setScopes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$this->id = "content";
$this->template = "login/login.tpl";
$this->layout = "common/layout-empty";
if (Registry::get('username')) {
header("Location: search.php");
exit;
}
$request = Registry::get('request');
$session = Registry::get('session');
$db = Registry::get('db');
$this->load->model('user/auth');
$this->load->model('user/user');
$this->load->model('user/prefs');
$this->load->model('domain/domain');
$this->load->model('folder/folder');
if (ENABLE_SAAS == 1) {
$this->load->model('saas/ldap');
$this->load->model('saas/customer');
}
$this->data['title'] = $this->data['text_login'];
$this->data['title_prefix'] = TITLE_PREFIX;
$this->data['failed_login_count'] = $this->model_user_auth->get_failed_login_count();
if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate() == true) {
if ($this->model_user_auth->checkLogin($this->request->post['username'], $_POST['password']) == 1) {
if ($session->get("ga_block") == 1) {
header("Location: " . SITE_URL . "index.php?route=login/ga");
exit;
} else {
$this->model_user_prefs->get_user_preferences($session->get('username'));
if (ENABLE_SAAS == 1) {
$this->model_saas_customer->online($session->get('email'));
}
LOGGER('logged in');
if (isAdminUser() == 1) {
header("Location: " . SITE_URL . "index.php?route=health/health");
exit;
}
header("Location: " . SITE_URL . "search.php");
exit;
}
} else {
$this->model_user_auth->increment_failed_login_count($this->data['failed_login_count']);
$this->data['failed_login_count']++;
}
$this->data['x'] = $this->data['text_invalid_email_or_password'];
}
if (ENABLE_GOOGLE_LOGIN == 1) {
$client = new apiClient();
$client->setApplicationName(GOOGLE_APPLICATION_NAME);
$client->setScopes(array('https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile', 'https://mail.google.com/'));
$client->setClientId(GOOGLE_CLIENT_ID);
$client->setClientSecret(GOOGLE_CLIENT_SECRET);
$client->setRedirectUri(GOOGLE_REDIRECT_URL);
$client->setDeveloperKey(GOOGLE_DEVELOPER_KEY);
$this->data['auth_url'] = $client->createAuthUrl();
}
$this->render();
}
示例2: getGoogleClient
private function getGoogleClient($config)
{
require_once LIBS_DIR . '/google-api-php-client/src/apiClient.php';
require_once LIBS_DIR . '/google-api-php-client/src/contrib/apiOauth2Service.php';
$client = new apiClient();
$client->setApplicationName($config['application_name']);
$client->setClientId($config['client_id']);
$client->setClientSecret($config['client_secret']);
$client->setRedirectUri($config['redirect_url']);
$client->setScopes(array('https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'));
return $client;
}
示例3: connect
/**
* connect
*/
protected function connect()
{
$client = new apiClient();
$client->setApplicationName("Google Application");
//*********** Replace with Your API Credentials **************
$client->setClientId($this->clientId);
$client->setClientSecret($this->clientSecret);
$client->setRedirectUri($this->redirectUri);
// $client->setDeveloperKey('AIzaSyBiUF9NmJKGwbJCDOQIoF2NxMgtYjwI1c8');
//************************************************************
$client->setScopes(array('https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/userinfo.email'));
return $client;
}
示例4: index
public function index()
{
$this->id = "content";
$this->template = "login/login.tpl";
$this->layout = "common/layout";
$request = Registry::get('request');
$db = Registry::get('db');
$session = Registry::get('session');
$this->load->model('user/auth');
$this->load->model('user/user');
$this->load->model('user/prefs');
$this->load->model('user/google');
$this->load->model('domain/domain');
$this->load->model('folder/folder');
$this->document->title = $this->data['text_login'];
$client = new apiClient();
$client->setApplicationName(GOOGLE_APPLICATION_NAME);
$client->setScopes(array('https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile', 'https://mail.google.com/'));
$client->setClientId(GOOGLE_CLIENT_ID);
$client->setClientSecret(GOOGLE_CLIENT_SECRET);
$client->setRedirectUri(GOOGLE_REDIRECT_URL);
$client->setDeveloperKey(GOOGLE_DEVELOPER_KEY);
$oauth2 = new apiOauth2Service($client);
if (isset($_GET['code'])) {
$client->authenticate();
$session->set("access_token", $client->getAccessToken());
header('Location: ' . GOOGLE_REDIRECT_URL);
}
if ($session->get("access_token")) {
$client->setAccessToken($session->get("access_token"));
}
if ($client->getAccessToken()) {
$session->set("access_token", $client->getAccessToken());
$token = json_decode($session->get("access_token"));
if (isset($token->{'access_token'}) && isset($token->{'refresh_token'})) {
$account = $oauth2->userinfo->get();
$this->model_user_google->check_for_account($account);
$this->model_user_google->update_tokens($account['email'], $account['id'], $token);
header("Location: " . SITE_URL . "search.php");
exit;
}
}
$this->render();
}
示例5: apiClient
*
* 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_once '../server.php';
require_once '../../key.php';
require_once 'src/apiClient.php';
session_start();
$client = new apiClient();
$client -> setApplicationName('Google Contacts');
$client -> setScopes("http://www.google.com/m8/feeds/");
$client -> setClientId(GOOGLE_CLIENT_ID);
$client -> setClientSecret(GOOGLE_CLIENT_SECRET);
$client -> setRedirectUri(AUTH_BASE_URL . '/gmail/index.php');
//$client->setDeveloperKey('insert_your_developer_key');
if (isset($_GET['code']))
{
$client -> authenticate();
$_SESSION['token'] = $client -> getAccessToken();
}
$match = false;
if (isset($_SESSION['token']))
示例6: define
* Copyright 2011 Google Inc.
*
* 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_once '../../src/apiClient.php';
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
$client = new apiClient();
// Visit https://code.google.com/apis/console to
// generate your oauth2_client_id, oauth2_client_secret, and to
// register your oauth2_redirect_uri.
//$client->setClientId('INSERT_CLIENT_ID');
//$client->setClientSecret('INSERT_CLIENT_SECRET');
$client->setRedirectUri('urn:ietf:wg:oauth:2.0:oob');
$client->setScopes(array('https://www.googleapis.com/auth/plus.me', 'https://www.googleapis.com/auth/latitude', 'https://www.googleapis.com/auth/moderator', 'https://www.googleapis.com/auth/tasks', 'https://www.googleapis.com/auth/siteverification', 'https://www.googleapis.com/auth/urlshortener', 'https://www.googleapis.com/auth/adsense.readonly'));
$authUrl = $client->createAuthUrl();
print "Please visit:\n{$authUrl}\n\n";
print "Please enter the auth code:\n";
$authCode = trim(fgets(STDIN));
$_GET['code'] = $authCode;
$accessToken = $client->authenticate();
var_dump($accessToken);
示例7: apiClient
<?php
require_once 'login/src/apiClient.php';
require_once 'login/src/contrib/apiOauth2Service.php';
$client = new apiClient();
$client->setApplicationName("flowerforevervn");
$client->setScopes(array('https://www.googleapis.com/auth/userinfo.email'));
//echo $authUrl = $client->createAuthUrl();
$oauth2 = new apiOauth2Service($client);
if (isset($_GET['code'])) {
$client->authenticate();
$_SESSION['token'] = $client->getAccessToken();
$redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
}
if (isset($_REQUEST['logout'])) {
unset($_SESSION['token']);
unset($_SESSION['google_data']);
//Google session data unset
$client->revokeToken();
}
if ($client->getAccessToken()) {
$user = $oauth2->userinfo->get();
//$_SESSION['google_data']=$user; // Storing Google User Data in Session
header("location: home.php");
$_SESSION['token'] = $client->getAccessToken();
} else {
$authUrl = $client->createAuthUrl();
示例8: apiClient
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require_once 'apiClient.php';
require_once 'apiPredictionService.php';
session_start();
$client = new apiClient();
$client->setApplicationName("Google Prediction API PHP Starter Application");
// Visit https://code.google.com/apis/console/?api=prediction to generate
// your oauth2_client_id, oauth2_client_secret, and to register your
// oauth2_redirect_uri.
// $client->setClientId('insert_your_oauth2_client_id');
// $client->setClientSecret('insert_your_oauth2_client_secret');
// $client->setRedirectUri('insert_your_oauth2_redirect_uri');
// $client->setDeveloperKey('insert_your_developer_key');
$client->setScopes(array('https://www.googleapis.com/auth/prediction'));
$predictionService = new apiPredictionService($client);
$trainedmodels = $predictionService->trainedmodels;
if (isset($_REQUEST['logout'])) {
unset($_SESSION['access_token']);
}
if (isset($_GET['code'])) {
$client->authenticate();
$_SESSION['access_token'] = $client->getAccessToken();
$redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}
if (isset($_SESSION['access_token'])) {
$client->setAccessToken($_SESSION['access_token']);
}
if ($client->getAccessToken()) {
示例9: test_service
public function test_service()
{
App::import("Vendor", "GoogleApiClient", array("file" => "google-api-php-client/src/apiClient.php"));
App::import("Vendor", "GoogleApiClient", array("file" => "google-api-php-client/src/contrib/apiBigqueryService.php"));
$apiClient = new apiClient();
$apiClient->setApplicationName("Testing App");
$apiClient->setClientId("632632109626-oi3e0cvvkbur75r1fe4cg80dbuk4sjds@developer.gserviceaccount.com");
$apiClient->setClientSecret("dhWNmyamq9LPLfMpWStQbmww");
$apiClient->setRedirectUri("http://" . $_SERVER['HTTP_HOST'] . "/tester/goog_callback");
$apiClient->setScopes(array('https://www.googleapis.com/auth/bigquery'));
$apiClient->authenticate();
}
示例10: apiClient
* 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_once 'src/apiClient.php';
require_once 'src/contrib/apiPlusService.php';
//session_start();
$client = new apiClient();
$client->setApplicationName("Takescript");
$client->setScopes(array('https://www.googleapis.com/auth/plus.me', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile'));
$plus = new apiPlusService($client);
if (isset($_REQUEST['logout'])) {
unset($_SESSION['access_token']);
}
if (isset($_GET['code'])) {
$client->authenticate();
$_SESSION['access_token'] = $client->getAccessToken();
header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}
if (isset($_SESSION['access_token'])) {
$client->setAccessToken($_SESSION['access_token']);
}
if ($client->getAccessToken()) {
$me = $plus->people->get('me');
$optParams = array('maxResults' => 100);
示例11: apiClient
<?php
session_start();
require_once "../src/apiClient.php";
$client = new apiClient();
$client->discover('plus');
$client->setScopes(array('https://www.googleapis.com/auth/plus.me'));
if (isset($_GET['logout'])) {
unset($_SESSION['token']);
}
if (isset($_GET['code'])) {
$client->authenticate();
$_SESSION['token'] = $client->getAccessToken();
header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
$ret = apiBatch::execute($client->plus->activities->list(array('userId' => 'me', 'collection' => 'public'), 'listActivities'), $client->plus->people->get(array('userId' => 'me'), 'getPerson'));
print "<pre>" . print_r($ret, true) . "</pre>";
} else {
$client->authenticate();
}
示例12: die
* See the License for the specific language governing permissions and
* limitations under the License.
*/
if (ini_get('register_globals') === "1") {
die("register_globals must be turned off before using the starter application");
}
require_once 'google-api-php-client/src/apiClient.php';
require_once 'google-api-php-client/src/contrib/apiPlusService.php';
session_start();
$client = new apiClient();
$client->setApplicationName("Get Friends Id");
$client->setClientId('1057327068472.apps.googleusercontent.com');
$client->setClientSecret('EOO__L0l3dn2i97W1OHN8KT8');
$client->setRedirectUri('http://localhost/googleplus/initialize.php');
$client->setDeveloperKey('AIzaSyCoR7Exd0QXZsvE8q5CaLGtVnAM3RPGeQY');
$client->setScopes(array('https://www.googleapis.com/auth/plus.me', 'https://www.google.com/m8/feeds/'));
$plus = new apiPlusService($client);
if (isset($_REQUEST['logout'])) {
unset($_SESSION['access_token']);
}
if (isset($_GET['code'])) {
$client->authenticate();
$_SESSION['access_token'] = $client->getAccessToken();
$redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}
if (isset($_SESSION['access_token'])) {
$client->setAccessToken($_SESSION['access_token']);
}
if ($client->getAccessToken()) {
$oToken = json_decode($client->getAccessToken());
示例13: define
* 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_once '../../src/apiClient.php';
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
global $apiConfig;
// Visit https://code.google.com/apis/console to
// generate your oauth2_client_id, oauth2_client_secret, and to
// register your oauth2_redirect_uri.
//$apiConfig['oauth2_client_id'] = 'INSERT_CLIENT_ID';
//$apiConfig['oauth2_client_secret'] = 'INSERT_CLIENT_SECRET';
$apiConfig['oauth2_redirect_uri'] = 'urn:ietf:wg:oauth:2.0:oob';
$apiConfig['authClass'] = 'apiOAuth2';
$client = new apiClient();
$client->setScopes(array('https://www.googleapis.com/auth/buzz', 'https://www.googleapis.com/auth/latitude', 'https://www.googleapis.com/auth/moderator', 'https://www.googleapis.com/auth/tasks', 'https://www.googleapis.com/auth/siteverification', 'https://www.googleapis.com/auth/urlshortener'));
$authUrl = $client->createAuthUrl();
print "Please visit:\n{$authUrl}\n\n";
print "Please enter the auth code:\n";
$authCode = trim(fgets(STDIN));
$_GET['code'] = $authCode;
$accessToken = $client->authenticate();
var_dump($accessToken);
示例14: initializeGooglePlusService
/**
* Initialize G+ service
* @return apiPlusService
*/
private function initializeGooglePlusService()
{
//get config
$nlGooglePlusIni = eZINI::instance('nlgoogleplus.ini');
//initialize Google+ API
$client = new apiClient();
$client->setApplicationName("NL Google Plus for eZ Publish");
// Visit https://code.google.com/apis/console to generate your
// oauth2_client_id, oauth2_client_secret, and to register your oauth2_redirect_uri.
$client->setClientId($nlGooglePlusIni->variable('GooglePlus', 'ClientId'));
$client->setClientSecret($nlGooglePlusIni->variable('GooglePlus', 'ClientSecret'));
$client->setDeveloperKey($nlGooglePlusIni->variable('GooglePlus', 'DeveloperKey'));
$client->setScopes(array($nlGooglePlusIni->variable('GooglePlus', 'Scope')));
//$client->setUseObjects(true);
return new apiPlusService($client);
}
示例15: apiClient
*
* 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.
*/
define('AUTH_SERVICE', 'google');
require_once '../server.php';
require_once 'googleapi/apiClient.php';
$client = new apiClient();
$client -> setApplicationName('tarfee.com');
$client -> setScopes(array(
"https://www.googleapis.com/auth/userinfo#email",
"https://www.googleapis.com/auth/userinfo.profile"
));
$client -> setClientId('846960227424-ngvickr83gflg38ehvapum82pm2jsefi.apps.googleusercontent.com');
$client -> setClientSecret('V4gH-18OqEqmilcSLQ1g5OyV');
$client -> setRedirectUri(AUTH_BASE_URL . '/google/index.php');
$access_token = NULL;
if (isset($_REQUEST['error']) && $_REQUEST['error'] == 'access_denied')
{
processDeniedAndExit('gmail');
exit();
}
if (isset($_GET['code']))