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


PHP Google_Client::setApplicationName方法代码示例

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


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

示例1: instantiateClient

 private function instantiateClient()
 {
     $this->client = new \Google_Client();
     $this->client->setApplicationName($this->config['applicationName']);
     $this->client->setAuthConfig($this->config['jsonFilePath']);
     $this->client->setScopes($this->config['scopes']);
 }
开发者ID:ozankurt,项目名称:google-core,代码行数:7,代码来源:Core.php

示例2: getGoogleApiClient

 /**
  * Returns an authorized API client.
  * @return Google_Client the authorized client object
  */
 private function getGoogleApiClient()
 {
     $client = new Google_Client();
     $client->setApplicationName($this->CFG['GOOGLE_API_APPLICATION_NAME']);
     $client->setScopes(Google_Service_Calendar::CALENDAR);
     $client->setAuthConfigFile($this->CFG['GOOGLE_API_CLIENT_SECRET_PATH']);
     $client->setAccessType('offline');
     // Load previously authorized credentials from a file.
     $credentialsPath = $this->CFG['GOOGLE_API_CREDENTIALS_PATH'];
     if (file_exists($credentialsPath)) {
         $accessToken = file_get_contents($credentialsPath);
     } else {
         // Request authorization from the user.
         $authUrl = $client->createAuthUrl();
         printf("Open the following link in your browser:\n%s\n", $authUrl);
         print 'Enter verification code: ';
         $authCode = trim(fgets(STDIN));
         // Exchange authorization code for an access token.
         $accessToken = $client->authenticate($authCode);
         // Store the credentials to disk.
         if (!file_exists(dirname($credentialsPath))) {
             mkdir(dirname($credentialsPath), 0700, true);
         }
         file_put_contents($credentialsPath, $accessToken);
         printf("Credentials saved to %s\n", $credentialsPath);
     }
     $client->setAccessToken($accessToken);
     // Refresh the token if it's expired.
     if ($client->isAccessTokenExpired()) {
         $client->refreshToken($client->getRefreshToken());
         file_put_contents($credentialsPath, $client->getAccessToken());
     }
     return $client;
 }
开发者ID:neocodesoftware,项目名称:NeoCode-FmUsage,代码行数:38,代码来源:class.GoogleApi.php

示例3: google

 function google()
 {
     $client = new Google_Client();
     $client->setApplicationName("snmmaurya");
     $client->setClientId(CLIENT_ID);
     $client->setClientSecret(CLIENT_SECRET);
     $client->setRedirectUri(REDIRECT_URI);
     $client->setApprovalPrompt(APPROVAL_PROMPT);
     $client->setAccessType(ACCESS_TYPE);
     $oauth2 = new Google_Oauth2Service($client);
     if (isset($_GET['code'])) {
         $client->authenticate($_GET['code']);
         $_SESSION['token'] = $client->getAccessToken();
     }
     if (isset($_SESSION['token'])) {
         $client->setAccessToken($_SESSION['token']);
     }
     if (isset($_REQUEST['error'])) {
         echo '<script type="text/javascript">window.close();</script>';
         exit;
     }
     if ($client->getAccessToken()) {
         $user = $oauth2->userinfo->get();
         $_SESSION['User'] = $user;
         $_SESSION['token'] = $client->getAccessToken();
     } else {
         $authUrl = $client->createAuthUrl();
         header('Location: ' . $authUrl);
     }
 }
开发者ID:business-expert,项目名称:bellimodeling,代码行数:30,代码来源:google.php

示例4: indexAction

 /**
  * @Route("/gatest2", name="front_ga2")
  *
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function indexAction(Request $request)
 {
     $this->client = $this->get('GoogleClient');
     $this->client->setAuthConfig($this->getParameter('googleCredentialsFile'));
     $this->client->setApplicationName('Pingvin');
     $this->client->setScopes($this->getParameter('googleAnalyticsAuthUrl'));
     $this->analyticsService = $this->get('GoogleAnalyticsService');
     $accounts = $this->analyticsService->management_accounts->listManagementAccounts();
     $data = array();
     if (count($accounts->getItems()) > 0) {
         $items = $accounts->getItems();
         foreach ($items as $item) {
             $id = $item->getId();
             $properties = $this->analyticsService->management_webproperties->listManagementWebproperties($id);
             $items_e = $properties->getItems();
             foreach ($items_e as $item_e) {
                 $profiles = $this->analyticsService->management_profiles->listManagementProfiles($id, $item_e->getId());
                 $items_ee = $profiles->getItems();
                 foreach ($items_ee as $item_ee) {
                     $data[] = array($item_ee->getId(), $item_e->getId());
                 }
             }
         }
         var_dump('<pre>', $data);
     }
     return $this->render('CronBundle::message.html.twig', array('message' => '...'));
 }
开发者ID:jarold87,项目名称:pingvin,代码行数:33,代码来源:gaTest2.php

示例5: __construct

 /**
  * Create a new Google  instance.
  *
  * @param array $config
  *
  * @return void
  */
 public function __construct(array $config)
 {
     $this->config = $config;
     $this->client = new \Google_Client();
     $this->client->setApplicationName("Tag media Mrs");
     $this->client->setDeveloperKey($config['developer_key']);
 }
开发者ID:heosua91,项目名称:googleq,代码行数:14,代码来源:GoogleQ.php

示例6:

 function __construct($API_SERVER_TOKEN)
 {
     $this->apiClient = new \Google_Client();
     $this->apiClient->setApplicationName("EHF-YouTube-Playlist");
     $this->apiClient->setDeveloperKey($API_SERVER_TOKEN);
     $this->apiService = new \Google_Service_YouTube($this->apiClient);
 }
开发者ID:roul1j,项目名称:typo3_youtube_playlist,代码行数:7,代码来源:YouTubeApi.php

示例7: __construct

 public function __construct(ContainerInterface $container, $api_key, $project_name)
 {
     $this->service_container = $container;
     $this->client = new \Google_Client();
     $this->client->setApplicationName($project_name);
     $this->client->setDeveloperKey($api_key);
     $this->searcher = new \Google_Service_Books($this->client);
 }
开发者ID:hellmark1990,项目名称:hmf,代码行数:8,代码来源:GoogleSearch.php

示例8: __construct

 /**
  * Google constructor.
  */
 public function __construct()
 {
     $this->_googleClient = new \Google_Client();
     $this->_googleClient->setClientId(KACANA_SOCIAL_GOOGLE_KEY);
     $this->_googleClient->setClientSecret(KACANA_SOCIAL_GOOGLE_SECRET);
     $this->_googleClient->setApplicationName(KACANA_SOCIAL_GOOGLE_APP_NAME);
     $this->_googleClient->setRedirectUri('postmessage');
 }
开发者ID:kacana,项目名称:kacana.com,代码行数:11,代码来源:Google.php

示例9: __construct

 /**
  * GoogleServiceProvider constructor.
  * @param $config
  */
 public function __construct()
 {
     $this->client = new \Google_Client();
     $this->projectName = config('google_cloud_storage.application');
     $this->projectBucket = config('google_cloud_storage.bucket');
     $this->authJsonFile = config('google_cloud_storage.auth_json_filename');
     $this->client->setApplicationName($this->projectName);
     $this->client->setAuthConfigFile(base_path($this->authJsonFile));
     $this->client->addScope(\Google_Service_Storage::DEVSTORAGE_FULL_CONTROL);
 }
开发者ID:io-digital,项目名称:google-cloud-storage,代码行数:14,代码来源:GoogleClient.php

示例10: __construct

 /**
  * GoogleServiceProvider constructor.
  * @param $config
  */
 public function __construct()
 {
     $this->client = new \Google_Client();
     $this->projectName = config('google_pub_sub.application');
     $this->authJsonFile = config('google_pub_sub.auth_json_filename');
     $this->client->setApplicationName($this->projectName);
     $this->client->setAuthConfigFile(base_path($this->authJsonFile));
     //THIS IS NEEDED FOR CHROME ENV
     //$this->client->useApplicationDefaultCredentials();
     $this->client->addScope(Google_Service_Pubsub::PUBSUB);
 }
开发者ID:io-digital,项目名称:google-pub-sub,代码行数:15,代码来源:GoogleClient.php

示例11: getClient

 /**
  * @return \Google_Client
  */
 public function getClient()
 {
     if ($this->_client == null) {
         $this->_client = new Google_Client();
         $this->_client->setApplicationName($this->appName);
         $key = file_get_contents(Yii::getAlias($this->keyFile));
         $cred = new Google_Auth_AssertionCredentials($this->serviceAccountEmail, $this->scopes, $key);
         $this->_client->setAssertionCredentials($cred);
         if ($this->_client->getAuth()->isAccessTokenExpired()) {
             $this->_client->getAuth()->refreshTokenWithAssertion($cred);
         }
     }
     return $this->_client;
 }
开发者ID:johnitvn,项目名称:mg075hynlo5793r5gt,代码行数:17,代码来源:GoogleClient.php

示例12: initializeClient

 public function initializeClient()
 {
     $this->client = new Client();
     $this->client->setAccessType('offline');
     $this->client->setApplicationName('playlister');
     $this->client->setClientId($this->config->get('services.youtube.client_id'));
     $this->client->setClientSecret($this->config->get('services.youtube.client_secret'));
     $this->client->setRedirectUri($this->config->get('services.youtube.redirect'));
     $this->client->setDeveloperKey($this->config->get('services.youtube.api_key'));
     $this->client->addScope('https://www.googleapis.com/auth/youtube.readonly');
     if ($this->auth->check() && $this->request->session()->has('user.token')) {
         $this->setToken($this->request->session()->get('user.token'));
     }
 }
开发者ID:JoeAlamo,项目名称:Playlister,代码行数:14,代码来源:YoutubeAPIService.php

示例13: initializeObject

 /**
  * Initialize the google calendar
  *
  * @throws \KevinDitscheid\KdCalendar\Exception\NoAuthDataException
  */
 public function initializeObject()
 {
     $this->settings = \KevinDitscheid\KdCalendar\Utility\ExtensionUtility::getMergedExtensionConfiguration();
     $this->client = new \Google_Client();
     $this->client->setApplicationName($this->settings['applicationName']);
     $this->client->setScopes(\Google_Service_Calendar::CALENDAR_READONLY);
     if ($this->settings['auth']['jsonFile']) {
         $this->client->setAuthConfigFile($this->settings['auth']['jsonFile']);
     } elseif ($this->settings['auth']['jsonString']) {
         $this->client->setAuthConfig($this->settings['auth']['jsonString']);
     } else {
         throw new \KevinDitscheid\KdCalendar\Exception\NoAuthDataException("No auth data is provided for Google Calendar!", 1454958940);
     }
     $this->client->setAccessType(self::ACCESS_TYPE_OFFLINE);
 }
开发者ID:bara0801,项目名称:kd_calendar,代码行数:20,代码来源:GoogleCalendarService.php

示例14: getClient

/**
 * Returns an authorized API client.
 * @return Google_Client the authorized client object
 */
function getClient()
{
    global $credentialsPath;
    $client = new Google_Client();
    $client->setApplicationName(APPLICATION_NAME);
    $client->setScopes(GAPI_SCOPES);
    $client->setAuthConfigFile(CLIENT_SECRET_PATH);
    $client->setAccessType('offline');


    if (file_exists($credentialsPath)) {
        $accessToken = file_get_contents($credentialsPath);
    } else {
        die("Please, get token via connect.php");
    }

    $client->setAccessToken($accessToken);

    // Refresh the token if it's expired.
    if ($client->isAccessTokenExpired()) {
        $client = refreshToken($client);
    }

    return $client;
}
开发者ID:ValentinNikolaev,项目名称:Asana-GDoc-reports,代码行数:29,代码来源:doc_list.php

示例15: getClient

function getClient()
{
    $config = (include __DIR__ . '/ini.php');
    $client = new Google_Client();
    $client->setApplicationName("Webkameleon");
    $client->setClientId($config['oauth2_client_id']);
    $client->setClientSecret($config['oauth2_client_secret']);
    $client->setRedirectUri($config['oauth2_redirect_uri']);
    $client->setScopes($config['oauth2_scopes']);
    $client->setState('offline');
    $client->setAccessType('offline');
    $client->setApprovalPrompt('force');
    if (isset($_GET['code'])) {
        $client->authenticate($_GET['code']);
        die($client->getAccessToken());
    } elseif (!isset($config['token'])) {
        Header('Location: ' . $client->createAuthUrl());
    } else {
        $client->setAccessToken($config['token']);
        if ($client->isAccessTokenExpired()) {
            $token = json_decode($config['token'], true);
            $client->refreshToken($token['refresh_token']);
        }
    }
    return $client;
}
开发者ID:podstawski,项目名称:appengine,代码行数:26,代码来源:google.php


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