当前位置: 首页>>代码示例>>PHP>>正文


PHP Google_Client::setUseObjects方法代码示例

本文整理汇总了PHP中Google_Client::setUseObjects方法的典型用法代码示例。如果您正苦于以下问题:PHP Google_Client::setUseObjects方法的具体用法?PHP Google_Client::setUseObjects怎么用?PHP Google_Client::setUseObjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Google_Client的用法示例。


在下文中一共展示了Google_Client::setUseObjects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: login

 /**
  * Login to facebook and get the associated cloudrexx user.
  */
 public function login()
 {
     $client = new \Google_Client();
     $client->setApplicationName('Contrexx Login');
     $client->setClientId($this->applicationData[0]);
     $client->setClientSecret($this->applicationData[1]);
     $client->setRedirectUri(\Cx\Lib\SocialLogin::getLoginUrl(self::OAUTH_PROVIDER));
     $client->setDeveloperKey($this->applicationData[2]);
     $client->setUseObjects(true);
     $client->setApprovalPrompt('auto');
     $client->setScopes(self::$scopes);
     self::$google = new \Google_Oauth2Service($client);
     self::$googleplus = new \Google_PlusService($client);
     if (isset($_GET['code'])) {
         try {
             $client->authenticate();
         } catch (\Google_AuthException $e) {
         }
     }
     if (!$client->getAccessToken()) {
         \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . $client->createAuthUrl());
         exit;
     }
     self::$userdata = $this->getUserData();
     $this->getContrexxUser(self::$userdata['oauth_id']);
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:29,代码来源:Google.class.php

示例2: createAnalyticsService

 /**
  * @return object | $service | Google Analytics Service Object used to run queries 
  **/
 private function createAnalyticsService()
 {
     /** 
      * Create and Authenticate Google Analytics Service Object
      **/
     $client = new Google_Client();
     $client->setApplicationName(GOOGLE_API_APP_NAME);
     /**
      * Makes sure Private Key File exists and is readable. If you get an error, check path in apiConfig.php
      **/
     if (!file_exists(GOOGLE_API_PRIVATE_KEY_FILE)) {
         array_push($GLOBALS['criticalErrors'], "CRITICAL-ERROR: Unable to find GOOGLE_API_PRIVATE_KEY_FILE p12 file at " . GOOGLE_API_PRIVATE_KEY_FILE);
         criticalErrorOccurred($criticalErrors, $errors);
         exit("CRITICAL-ERROR: Unable to find GOOGLE_API_PRIVATE_KEY_FILE p12 file at " . GOOGLE_API_PRIVATE_KEY_FILE . ' Backup aborted.');
     } elseif (!is_readable(GOOGLE_API_PRIVATE_KEY_FILE)) {
         array_push($GLOBALS['criticalErrors'], "CRITICAL-ERROR: Unable to read GOOGLE_API_PRIVATE_KEY_FILE p12 file at " . GOOGLE_API_PRIVATE_KEY_FILE);
         criticalErrorOccurred($criticalErrors, $errors);
         exit("CRITICAL-ERROR: Unable to read GOOGLE_API_PRIVATE_KEY_FILE p12 file at " . GOOGLE_API_PRIVATE_KEY_FILE . ' Backup aborted.');
     }
     $client->setAssertionCredentials(new Google_AssertionCredentials(GOOGLE_API_SERVICE_EMAIL, array('https://www.googleapis.com/auth/analytics.readonly'), file_get_contents(GOOGLE_API_PRIVATE_KEY_FILE)));
     $client->setClientId(GOOGLE_API_SERVICE_CLIENT_ID);
     $client->setUseObjects(true);
     $service = new Google_AnalyticsService($client);
     return $service;
 }
开发者ID:israbbani,项目名称:analytics-archiver,代码行数:28,代码来源:Analytics.class.php

示例3: testSettersGetters

 public function testSettersGetters()
 {
     $client = new Google_Client();
     $client->setClientId("client1");
     $client->setClientSecret('client1secret');
     $client->setState('1');
     $client->setApprovalPrompt('force');
     $client->setAccessType('offline');
     global $apiConfig;
     $this->assertEquals('client1', $apiConfig['oauth2_client_id']);
     $this->assertEquals('client1secret', $apiConfig['oauth2_client_secret']);
     $client->setRedirectUri('localhost');
     $client->setApplicationName('me');
     $client->setUseObjects(false);
     $this->assertEquals('object', gettype($client->getAuth()));
     $this->assertEquals('object', gettype($client->getCache()));
     $this->assertEquals('object', gettype($client->getIo()));
     $client->setAuthClass('Google_AuthNone');
     $client->setAuthClass('Google_OAuth2');
     try {
         $client->setAccessToken(null);
         die('Should have thrown an Google_AuthException.');
     } catch (Google_AuthException $e) {
         $this->assertEquals('Could not json decode the token', $e->getMessage());
     }
     $token = json_encode(array('access_token' => 'token'));
     $client->setAccessToken($token);
     $this->assertEquals($token, $client->getAccessToken());
 }
开发者ID:ricain59,项目名称:fortaff,代码行数:29,代码来源:ApiClientTest.php

示例4: getGoogleClient

 /**
  * @return \Google_Client
  */
 protected function getGoogleClient($redirectUrl)
 {
     if (!$this->_googleClient) {
         $this->_googleClient = new \Google_Client();
         $this->_googleClient->setUseObjects(TRUE);
         $this->_googleClient->setApplicationName($this->applicationName);
         $this->_googleClient->setAssertionCredentials(new \Google_AssertionCredentials($this->clientMail, array('https://www.googleapis.com/auth/analytics.readonly'), file_get_contents($this->keyFile)));
         $this->_googleClient->setClientId($this->clientId);
         $this->_googleClient->setRedirectUri($redirectUrl);
     }
     return $this->_googleClient;
 }
开发者ID:svobodni,项目名称:web,代码行数:15,代码来源:AnalyticsManager.php

示例5: processAuth

 /**
  * This method is used to process the second part of authentication workflow, after redirect
  *
  * @return array Array with status and user details
  */
 public function processAuth()
 {
     $ngConnectINI = eZINI::instance('ngconnect.ini');
     $http = eZHTTPTool::instance();
     $clientID = trim($ngConnectINI->variable('LoginMethod_google', 'GoogleClientID'));
     $clientSecret = trim($ngConnectINI->variable('LoginMethod_google', 'GoogleClientSecret'));
     if (empty($clientID) || empty($clientSecret)) {
         return array('status' => 'error', 'message' => 'Google client ID or Google client secret undefined.');
     }
     $code = trim($http->getVariable('code', ''));
     $state = trim($http->getVariable('state', ''));
     if (empty($code) || empty($state)) {
         return array('status' => 'error', 'message' => 'code or state GET parameters undefined.');
     }
     if (!$http->hasSessionVariable('NGConnectOAuthState') || $state != $http->sessionVariable('NGConnectOAuthState')) {
         $http->removeSessionVariable('NGConnectOAuthState');
         return array('status' => 'error', 'message' => 'State parameter does not match stored value.');
     } else {
         $http->removeSessionVariable('NGConnectOAuthState');
     }
     $callbackUri = self::CALLBACK_URI_PART;
     $loginWindowType = trim($ngConnectINI->variable('ngconnect', 'LoginWindowType'));
     if ($loginWindowType == 'popup') {
         $callbackUri = '/layout/set/ngconnect' . self::CALLBACK_URI_PART;
     }
     eZURI::transformURI($callbackUri, false, 'full');
     $scope = self::SCOPE;
     $userScope = trim($ngConnectINI->variable('LoginMethod_google', 'Scope'));
     if (!empty($userScope)) {
         $scope = $userScope . ' ' . $scope;
     }
     $client = new Google_Client();
     $client->setApplicationName(trim($ngConnectINI->variable('LoginMethod_google', 'MethodName')));
     $client->setScopes($scope);
     $client->setClientId($clientID);
     $client->setClientSecret($clientSecret);
     $client->setRedirectUri($callbackUri);
     $client->setUseObjects(true);
     $plus = new Google_PlusService($client);
     $authString = $client->authenticate();
     $accessToken = $client->getAccessToken();
     if (empty($authString) || empty($accessToken)) {
         return array('status' => 'error', 'message' => 'Unable to authenticate to Google.');
     }
     $me = $plus->people->get('me');
     if (!$me instanceof Google_Person) {
         return array('status' => 'error', 'message' => 'Invalid Google user.');
     }
     $result = array('status' => 'success', 'login_method' => 'google', 'id' => $me->id, 'first_name' => !empty($me->name->givenName) ? $me->name->givenName : '', 'last_name' => !empty($me->name->familyName) ? $me->name->familyName : '', 'email' => !empty($me->emails[0]['value']) ? $me->emails[0]['value'] : '', 'picture' => !empty($me->image->url) ? $me->image->url : '');
     return $result;
 }
开发者ID:netgen,项目名称:ngconnect,代码行数:56,代码来源:ngconnectauthgoogle.php

示例6: __construct

 public function __construct()
 {
     parent::__construct();
     $this->callbackurl = 'http://tiny4cocoa.com/homeadmin/settongji/';
     $client = new Google_Client();
     $client->setClientId('70232315343-0nikjc44hcpfk5qt93pe0e21sc2u3ntm.apps.googleusercontent.com');
     $client->setClientSecret('8I4c4toq6hYE6i3BhHhjRrIc');
     $client->setRedirectUri($this->callbackurl);
     $client->setDeveloperKey('AIzaSyBE9EKeqtgJntWuNbDekaPSNvu9ZalXFpE');
     $client->setScopes(array('https://www.googleapis.com/auth/analytics.readonly'));
     $client->setUseObjects(true);
     $service = new Google_AnalyticsService($client);
     $this->client = $client;
     $this->service = $service;
 }
开发者ID:lilhorse,项目名称:cocoa,代码行数:15,代码来源:TongjiModel.php

示例7: __construct

 public function __construct($params)
 {
     if (isset($params['configured']) && $params['configured'] === 'true' && isset($params['client_id']) && isset($params['client_secret']) && isset($params['token'])) {
         $client = new \Google_Client();
         $client->setClientId($params['client_id']);
         $client->setClientSecret($params['client_secret']);
         $client->setScopes(array('https://www.googleapis.com/auth/drive'));
         $client->setUseObjects(true);
         $client->setAccessToken($params['token']);
         $this->service = new \Google_DriveService($client);
         $token = json_decode($params['token'], true);
         $this->id = 'google::' . substr($params['client_id'], 0, 30) . $token['created'];
     } else {
         throw new \Exception('Creating \\OC\\Files\\Storage\\Google storage failed');
     }
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:16,代码来源:google.php

示例8: get_google_api_client

function get_google_api_client()
{
    global $api_client_id, $api_client_secret, $api_simple_key, $base_url;
    // Set your cached access token. Remember to replace $_SESSION with a
    // real database or memcached.
    session_start();
    $client = new Google_Client();
    $client->setUseObjects(true);
    $client->setApplicationName('Google Mirror API PHP Quick Start');
    // These are set in config.php
    $client->setClientId($api_client_id);
    $client->setClientSecret($api_client_secret);
    $client->setRedirectUri($base_url . "/oauth2callback.php");
    $client->setScopes(array('https://www.googleapis.com/auth/glass.timeline', 'https://www.googleapis.com/auth/glass.location', 'https://www.googleapis.com/auth/userinfo.profile'));
    return $client;
}
开发者ID:rafasashi,项目名称:mirror-quickstart-php,代码行数:16,代码来源:mirror-client.php

示例9: getBaseClient

 public static function getBaseClient($state = null)
 {
     if (!self::$_baseClient) {
         $cfg = self::_getApiConfig();
         $client = new Google_Client();
         $client->setApplicationName($cfg['appName']);
         $client->setClientId($cfg['clientId']);
         $client->setClientSecret($cfg['clientSecret']);
         $client->setRedirectUri(self::_getRedirectUrl());
         $client->setAccessType($cfg['accessType']);
         $client->setUseObjects($cfg['useObjects']);
         if ($state) {
             $client->setState($state);
         }
         self::$_baseClient = $client;
     }
     return self::$_baseClient;
 }
开发者ID:Rademade,项目名称:MedOptima,代码行数:18,代码来源:Config.php

示例10: getClient

 public function getClient(Scalr_Environment $environment, $cloudLocation)
 {
     $client = new Google_Client();
     $client->setApplicationName("Scalr GCE");
     $client->setScopes(array('https://www.googleapis.com/auth/compute'));
     $key = base64_decode($environment->getPlatformConfigValue(self::KEY));
     $client->setAssertionCredentials(new Google_AssertionCredentials($environment->getPlatformConfigValue(self::SERVICE_ACCOUNT_NAME), array('https://www.googleapis.com/auth/compute'), $key));
     $client->setUseObjects(true);
     $client->setClientId($environment->getPlatformConfigValue(self::CLIENT_ID));
     $gce = new Google_ComputeService($client);
     //**** Store access token ****//
     $jsonAccessToken = $environment->getPlatformConfigValue(self::ACCESS_TOKEN);
     $accessToken = @json_decode($jsonAccessToken);
     if ($accessToken && $accessToken->created + $accessToken->expires_in > time()) {
         $client->setAccessToken($jsonAccessToken);
     } else {
         $gce->zones->listZones($environment->getPlatformConfigValue(self::PROJECT_ID));
         $token = $client->getAccessToken();
         $environment->setPlatformConfig(array(self::ACCESS_TOKEN => $token));
     }
     return $gce;
 }
开发者ID:recipe,项目名称:scalr,代码行数:22,代码来源:GoogleCE.php

示例11: xGetMachineTypesAction

 public function xGetMachineTypesAction()
 {
     $p = PlatformFactory::NewPlatform(SERVER_PLATFORMS::GCE);
     $client = new Google_Client();
     $client->setApplicationName("Scalr GCE");
     $client->setScopes(array('https://www.googleapis.com/auth/compute'));
     $key = base64_decode($this->environment->getPlatformConfigValue(Modules_Platforms_GoogleCE::KEY));
     $client->setAssertionCredentials(new Google_AssertionCredentials($this->environment->getPlatformConfigValue(Modules_Platforms_GoogleCE::SERVICE_ACCOUNT_NAME), array('https://www.googleapis.com/auth/compute'), $key));
     $client->setUseObjects(true);
     $client->setClientId($this->environment->getPlatformConfigValue(Modules_Platforms_GoogleCE::CLIENT_ID));
     $projectId = $this->environment->getPlatformConfigValue(Modules_Platforms_GoogleCE::PROJECT_ID);
     $gceClient = new Google_ComputeService($client);
     $data['types'] = array();
     $data['dbTypes'] = array();
     $types = $gceClient->machineTypes->listMachineTypes($projectId, $this->getParam('cloudLocation'));
     foreach ($types->items as $item) {
         $isEphemeral = substr($item->name, -2) == '-d';
         if (!$isEphemeral) {
             $data['types'][] = array('name' => $item->name, 'description' => "{$item->name} ({$item->description})");
         }
     }
     $this->response->data(array('data' => $data));
 }
开发者ID:recipe,项目名称:scalr,代码行数:23,代码来源:Gce.php

示例12: getGoogleClient

function getGoogleClient()
{
    require_once 'google-api-php-client/src/Google_Client.php';
    require_once 'google-api-php-client/src/contrib/Google_CalendarService.php';
    global $google_api;
    extract($google_api);
    $client = new Google_Client();
    $client->setUseObjects(true);
    $client->setAccessType('offline');
    $client->setApplicationName($ApplicationName);
    $client->setClientId($ClientId);
    $client->setClientSecret($ClientSecret);
    $client->setRedirectUri($RedirectUri);
    $client->refreshToken($accessToken);
    $cal = new Google_CalendarService($client);
    return $cal;
}
开发者ID:jrgsf,项目名称:giggity,代码行数:17,代码来源:requests.php

示例13: getUserInfo

 /**
  * Send a request to the UserInfo API to retrieve the user's information.
  *
  * @param String credentials OAuth 2.0 credentials to authorize the request.
  * @return Userinfo User's information.
  */
 public static function getUserInfo($credentials, $client_id, $client_secret)
 {
     require_once CASH_PLATFORM_ROOT . '/lib/google/Google_Client.php';
     require_once CASH_PLATFORM_ROOT . '/lib/google/contrib/Google_Oauth2Service.php';
     $client = new Google_Client();
     $client->setUseObjects(false);
     $client->setClientId($client_id);
     $client->setClientSecret($client_secret);
     $client->setAccessToken($credentials);
     $service = new Google_Oauth2Service($client);
     $user_info = null;
     try {
         $user_info = $service->userinfo->get();
     } catch (Google_Exception $e) {
         // $this->error_message = 'An error occurred: ' . $e->getMessage();
         return false;
     }
     if (is_array($user_info)) {
         return $user_info;
     } else {
         return false;
     }
 }
开发者ID:JamesLinus,项目名称:platform,代码行数:29,代码来源:GoogleDriveSeed.php

示例14: buildService

 public function buildService($userEmail)
 {
     session_start();
     $DRIVE_SCOPE = 'https://www.googleapis.com/auth/drive';
     $SERVICE_ACCOUNT_EMAIL = '388164385292-p3a5862lsjtrgv2g3s540nea9e3r589f@developer.gserviceaccount.com';
     $SERVICE_ACCOUNT_PKCS12_FILE_PATH = '/Users/shwetasabne/aboutme/shwetasabne/public/resources/API Project-ba0bc0c8779d.p12';
     $key = file_get_contents($SERVICE_ACCOUNT_PKCS12_FILE_PATH);
     $auth = new Google_AssertionCredentials($SERVICE_ACCOUNT_EMAIL, array($DRIVE_SCOPE), $key);
     $auth->sub = 'admin@shwetasabne.com';
     $client = new Google_Client();
     $client->setUseObjects(true);
     $client->setAssertionCredentials($auth);
     //var_dump(new Google_DriveService($client));
     return new Google_DriveService($client);
 }
开发者ID:shwetasabne,项目名称:laravelproject,代码行数:15,代码来源:AboutController.php

示例15: ga_dash_content

function ga_dash_content()
{
    require_once 'functions.php';
    if (!get_option('ga_dash_cachetime') or get_option('ga_dash_cachetime') == 10) {
        update_option('ga_dash_cachetime', "900");
    }
    if (!class_exists('Google_Exception')) {
        require_once 'src/Google_Client.php';
    }
    require_once 'src/contrib/Google_AnalyticsService.php';
    //$scriptUri = "http://".$_SERVER["HTTP_HOST"].$_SERVER['PHP_SELF'];
    $client = new Google_Client();
    $client->setAccessType('offline');
    $client->setApplicationName('Google Analytics Dashboard');
    $client->setRedirectUri('urn:ietf:wg:oauth:2.0:oob');
    if (get_option('ga_dash_userapi')) {
        $client->setClientId(get_option('ga_dash_clientid'));
        $client->setClientSecret(get_option('ga_dash_clientsecret'));
        $client->setDeveloperKey(get_option('ga_dash_apikey'));
    } else {
        $client->setClientId('65556128781.apps.googleusercontent.com');
        $client->setClientSecret('Kc7888wgbc_JbeCpbFjnYpwE');
        $client->setDeveloperKey('AIzaSyBG7LlUoHc29ZeC_dsShVaBEX15SfRl_WY');
    }
    $service = new Google_AnalyticsService($client);
    if (ga_dash_get_token()) {
        $token = ga_dash_get_token();
        $client->setAccessToken($token);
    }
    if (!$client->getAccessToken()) {
        $authUrl = $client->createAuthUrl();
        if (!isset($_REQUEST['ga_dash_authorize'])) {
            if (!current_user_can('manage_options')) {
                _e("Ask an admin to authorize this Application", 'ga-dash');
                return;
            }
            echo '<div style="padding:20px;">' . __("Use this link to get your access code:", 'ga-dash') . ' <a href="' . $authUrl . '" target="_blank">' . __("Get Access Code", 'ga-dash') . '</a>';
            echo '<form name="input" action="#" method="get">
						<p><b>' . __("Access Code:", 'ga-dash') . ' </b><input type="text" name="ga_dash_code" value="" size="61"></p>
						<input type="submit" class="button button-primary" name="ga_dash_authorize" value="' . __("Save Access Code", 'ga-dash') . '"/>
					</form>
				</div>';
            return;
        } else {
            if ($_REQUEST['ga_dash_code']) {
                $client->authenticate($_REQUEST['ga_dash_code']);
                ga_dash_store_token($client->getAccessToken());
            } else {
                $adminurl = admin_url("#ga-dash-widget");
                echo '<script> window.location="' . $adminurl . '"; </script> ';
            }
        }
    }
    if (current_user_can('manage_options')) {
        if (isset($_REQUEST['ga_dash_profiles'])) {
            update_option('ga_dash_tableid', $_REQUEST['ga_dash_profiles']);
        }
        try {
            $client->setUseObjects(true);
            $profile_switch = "";
            $serial = 'gadash_qr1';
            $transient = get_transient($serial);
            if (empty($transient)) {
                $profiles = $service->management_profiles->listManagementProfiles('~all', '~all');
                set_transient($serial, $profiles, 60 * 60 * 24);
            } else {
                $profiles = $transient;
            }
            //print_r($profiles);
            $items = $profiles->getItems();
            $profile_switch .= '<form><select id="ga_dash_profiles" name="ga_dash_profiles" onchange="this.form.submit()">';
            if (count($items) != 0) {
                $ga_dash_profile_list = "";
                foreach ($items as &$profile) {
                    if (!get_option('ga_dash_tableid')) {
                        update_option('ga_dash_tableid', $profile->getId());
                    }
                    $profile_switch .= '<option value="' . $profile->getId() . '"';
                    if (get_option('ga_dash_tableid') == $profile->getId()) {
                        $profile_switch .= "selected='yes'";
                    }
                    $profile_switch .= '>' . ga_dash_get_profile_domain($profile->getwebsiteUrl()) . '</option>';
                    $ga_dash_profile_list[] = array($profile->getName(), $profile->getId(), $profile->getwebPropertyId(), $profile->getwebsiteUrl());
                }
                update_option('ga_dash_profile_list', $ga_dash_profile_list);
            }
            $profile_switch .= "</select></form><br />";
            $client->setUseObjects(false);
        } catch (Google_ServiceException $e) {
            echo ga_dash_pretty_error($e);
            return;
        }
    }
    if (current_user_can('manage_options')) {
        if (get_option('ga_dash_jailadmins')) {
            if (get_option('ga_dash_tableid_jail')) {
                $projectId = get_option('ga_dash_tableid_jail');
            } else {
                _e("Ask an admin to asign a Google Analytics Profile", 'ga-dash');
                return;
//.........这里部分代码省略.........
开发者ID:Paulf-999,项目名称:HollyFry.com,代码行数:101,代码来源:ga_dash.php


注:本文中的Google_Client::setUseObjects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。