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


PHP Google_Config::setApplicationName方法代码示例

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


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

示例1: get

 public function get()
 {
     $callback = 'http://api.soundeavor.com/User/Auth/Login/Google/index.php';
     $config = new \Google_Config();
     $config->setApplicationName('Soundeavor');
     $config->setClientId(Config::getConfig('GoogleClientId'));
     $config->setClientSecret(Config::getConfig('GoogleClientSecret'));
     $config->setRedirectUri($callback);
     $client = new \Google_Client($config);
     /*
      * Add scopes (permissions) for the client https://developers.google.com/oauthplayground/
      */
     $client->addScope('https://www.googleapis.com/auth/plus.me');
     if (!isset($_GET['code'])) {
         $loginUrl = $client->createAuthUrl();
         header('Location: ' . $loginUrl);
     }
     $code = $_GET['code'];
     $client->authenticate($code);
     $accessToken = $client->getAccessToken();
     $accessToken = $accessToken['access_token'];
     $service = new \Google_Service_Plus($client);
     $scopes = $service->availableScopes;
     print_r($scopes);
     die;
 }
开发者ID:kris-nova,项目名称:API,代码行数:26,代码来源:Google.php

示例2: get_google_client

/**
 * Wrapper to get a Google Client object.
 *
 * This automatically sets the config to Moodle's defaults.
 *
 * @return Google_Client
 */
function get_google_client()
{
    global $CFG, $SITE;
    make_temp_directory('googleapi');
    $tempdir = $CFG->tempdir . '/googleapi';
    $config = new Google_Config();
    $config->setApplicationName('Moodle ' . $CFG->release);
    $config->setIoClass('moodle_google_curlio');
    $config->setClassConfig('Google_Cache_File', 'directory', $tempdir);
    $config->setClassConfig('Google_Auth_OAuth2', 'access_type', 'online');
    $config->setClassConfig('Google_Auth_OAuth2', 'approval_prompt', 'auto');
    return new Google_Client($config);
}
开发者ID:educakanchay,项目名称:campus,代码行数:20,代码来源:lib.php

示例3: setApplicationName

 /**
  * Set the application name, this is included in the User-Agent HTTP header.
  * @param string $applicationName
  */
 public function setApplicationName($applicationName)
 {
     $this->config->setApplicationName($applicationName);
 }
开发者ID:hzhou9,项目名称:coupon_deal,代码行数:8,代码来源:Client.php

示例4: register

 public function register(Application $app)
 {
     $app['gapi.services'] = $app->share(function () use($app) {
         $path = __DIR__ . '/../Resources/services.json';
         $data = file_get_contents($path);
         return json_decode($data, true);
     });
     $app['gapi.scopes'] = $app->share(function () use($app) {
         $path = __DIR__ . '/../Resources/scopes.json';
         $data = file_get_contents($path);
         return json_decode($data, true);
     });
     $app['gapi.config'] = $app->share(function () use($app) {
         $options = $app['gapi.options'];
         $config = new \Google_Config();
         if (isset($options['application_name'])) {
             $config->setApplicationName($options['application_name']);
         }
         if (isset($options['client_id'])) {
             $config->setClientId($options['client_id']);
         }
         if (isset($options['client_secret'])) {
             $config->setClientSecret($options['client_secret']);
         }
         if (isset($options['redirect_uri'])) {
             $config->setRedirectUri($options['redirect_uri']);
         }
         if (isset($options['access_type'])) {
             $config->setAccessType($options['access_type']);
         }
         if (isset($options['approval_prompt'])) {
             $config->setApprovalPrompt($options['approval_prompt']);
         }
         if (isset($options['developer_key'])) {
             $config->setDeveloperKey($options['developer_key']);
         }
         return $config;
     });
     $app['gapi.client'] = $app->share(function () use($app) {
         $options = $app['gapi.options'];
         $client = new \Google_Client($app['gapi.config']);
         foreach (array('scope', 'scopes') as $key) {
             if (isset($options[$key]) && $options[$key]) {
                 $scopes = $options[$key];
                 if (!is_array($scopes)) {
                     $scopes = array($scopes);
                 }
                 foreach ($scopes as $scope) {
                     if (isset($app['gapi.scopes'][strtolower($scope)])) {
                         $scope = $app['gapi.scopes'][strtolower($scope)];
                     }
                     $client->addScope($scope);
                 }
             }
         }
         if (isset($options['refresh_token'])) {
             $client->refreshToken($options['refresh_token']);
         }
         return $client;
     });
     $app['gapi.access_token'] = function () use($app) {
         $token = json_decode($app['gapi.client']->getAccessToken());
         if (is_object($token) && isset($token->access_token)) {
             return $token->access_token;
         } else {
             return null;
         }
     };
     foreach ($app['gapi.services'] as $service => $classname) {
         $app['gapi.service.' . $service] = $app->share(function () use($app, $classname) {
             $class = new \ReflectionClass($classname);
             return $class->newInstance($app['gapi.client']);
         });
     }
 }
开发者ID:shineunited,项目名称:googleclient,代码行数:75,代码来源:GoogleClientServiceProvider.php


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