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


PHP apiClient::setAccessType方法代码示例

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


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

示例1: testSettersGetters

 public function testSettersGetters()
 {
     $client = new apiClient();
     $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('apiAuthNone');
     $client->setAuthClass('apiOAuth2');
     try {
         $client->setAccessToken(null);
         die('Should have thrown an apiAuthException.');
     } catch (apiAuthException $e) {
         $this->assertEquals('Could not json decode the access token', $e->getMessage());
     }
     $token = json_encode(array('access_token' => 'token'));
     $client->setAccessToken($token);
     $this->assertEquals($token, $client->getAccessToken());
 }
开发者ID:rahij,项目名称:ivlesync,代码行数:29,代码来源:ApiClientTest.php

示例2: __construct

 /**
  * Constructor and Login
  * @param $buy
  * @return Oara_Network_Publisher_Buy_Api
  */
 public function __construct($credentials)
 {
     $client = new apiClient();
     $client->setApplicationName("AffJet");
     $client->setClientId($credentials['clientId']);
     $client->setClientSecret($credentials['clientSecret']);
     $client->setAccessToken($credentials['oauth2']);
     $client->setAccessType('offline');
     $this->_client = $client;
     $this->_gan = new apiGanService($client);
 }
开发者ID:netzkind,项目名称:php-oara,代码行数:16,代码来源:GoogleAffiliateNetwork.php

示例3: apiClient

<?php

session_start();
/******Improting Facebook API Files**************/
require_once 'includes/google-api-php-client/apiClient.php';
require_once 'includes/google-api-php-client/contrib/apiOauth2Service.php';
require_once 'credentials.php';
require_once 'sqlFunctions.php';
/******Google API Connection With My APP**************/
$client = new apiClient();
//$client->setApplicationName("TheASP");
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setDeveloperKey($api_key);
$client->setRedirectUri($redirect_url);
$client->setAccessType('online');
$client->setApprovalPrompt('auto');
$oauth2 = new apiOauth2Service($client);
/******Waiting For OAuth Token And Then Authenticating**************/
if (isset($_GET['code'])) {
    $client->authenticate();
    /******After Authentication Requesting For User Data******/
    $info = $oauth2->userinfo->get();
    //echo '<pre>' . print_r( $info, 1 ) . '</pre>';
}
$email = $info['email'];
$fullname = $info['name'];
$fname = $info['given_name'];
$lname = $info['family_name'];
$Fuid = $info['id'];
$fblink = $info['link'];
开发者ID:vipinkhushu,项目名称:Sign-In-Via-Facebook-Google-Twitter,代码行数:31,代码来源:collectUserDataGoogle.php

示例4: actionSyncActionsToGoogleCalendar

 public function actionSyncActionsToGoogleCalendar()
 {
     $model = Yii::app()->params->profile;
     if (isset($_POST['ProfileChild'])) {
         foreach (array_keys($model->attributes) as $field) {
             if (isset($_POST['ProfileChild'][$field])) {
                 $model->{$field} = $_POST['ProfileChild'][$field];
             }
         }
         if ($model->syncGoogleCalendarId && isset($_SESSION['token'])) {
             $token = json_decode($_SESSION['token'], true);
             $model->syncGoogleCalendarRefreshToken = $token['refresh_token'];
             // used for accessing this google calendar at a later time
             $model->syncGoogleCalendarAccessToken = $_SESSION['token'];
         }
         $model->update();
     }
     $admin = Yii::app()->params->admin;
     $googleIntegration = $admin->googleIntegration;
     // if google integration is activated let user choose if they want to link this calendar to a google calendar
     if ($googleIntegration) {
         $timezone = date_default_timezone_get();
         require_once "protected/extensions/google-api-php-client/src/apiClient.php";
         require_once "protected/extensions/google-api-php-client/src/contrib/apiCalendarService.php";
         date_default_timezone_set($timezone);
         $client = new apiClient();
         $syncGoogleCalendarName = null;
         // name of the Google Calendar that current user's actions are being synced to if it has been set
         if (isset($_GET['unlinkGoogleCalendar'])) {
             // user changed thier mind about linking their google calendar
             unset($_SESSION['token']);
             $model->syncGoogleCalendarId = null;
             $model->syncGoogleCalendarRefreshToken = null;
             // used for accessing this google calendar at a later time
             $model->syncGoogleCalendarAccessToken = null;
             $model->update();
             $googleCalendarList = null;
             $client->setApplicationName("Google Calendar Integration");
             // Visit https://code.google.com/apis/console?api=calendar to generate your
             // client id, client secret, and to register your redirect uri.
             $client->setClientId($admin->googleClientId);
             $client->setClientSecret($admin->googleClientSecret);
             $client->setRedirectUri((@$_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $this->createUrl(''));
             $client->setDeveloperKey($admin->googleAPIKey);
             $client->setAccessType('offline');
             $googleCalendar = new apiCalendarService($client);
             if (isset($_GET['code'])) {
                 // returning from google with access token
                 $client->authenticate();
                 $_SESSION['token'] = $client->getAccessToken();
                 header('Location: ' . (@$_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
             }
             if (isset($_SESSION['token'])) {
                 $client->setAccessToken($_SESSION['token']);
                 $calList = $googleCalendar->calendarList->listCalendarList();
                 $googleCalendarList = array();
                 foreach ($calList['items'] as $cal) {
                     $googleCalendarList[$cal['id']] = $cal['summary'];
                 }
             } else {
                 $googleCalendarList = null;
             }
         } else {
             if ($model->syncGoogleCalendarRefreshToken) {
                 $client->setClientId($admin->googleClientId);
                 $client->setClientSecret($admin->googleClientSecret);
                 $client->setDeveloperKey($admin->googleAPIKey);
                 $client->setAccessToken($model->syncGoogleCalendarAccessToken);
                 $googleCalendar = new apiCalendarService($client);
                 // check if the access token needs to be refreshed
                 // note that the google library automatically refreshes the access token if we need a new one,
                 // we just need to check if this happend by calling a google api function that requires authorization,
                 // and, if the access token has changed, save this new access token
                 $testCal = $googleCalendar->calendars->get($model->syncGoogleCalendarId);
                 if ($model->syncGoogleCalendarAccessToken != $client->getAccessToken()) {
                     $model->syncGoogleCalendarAccessToken = $client->getAccessToken();
                     $model->update();
                 }
                 $calendar = $googleCalendar->calendars->get($model->syncGoogleCalendarId);
                 $syncGoogleCalendarName = $calendar['summary'];
                 $calList = $googleCalendar->calendarList->listCalendarList();
                 $googleCalendarList = array();
                 foreach ($calList['items'] as $cal) {
                     $googleCalendarList[$cal['id']] = $cal['summary'];
                 }
             } else {
                 $client->setApplicationName("Google Calendar Integration");
                 // Visit https://code.google.com/apis/console?api=calendar to generate your
                 // client id, client secret, and to register your redirect uri.
                 $client->setClientId($admin->googleClientId);
                 $client->setClientSecret($admin->googleClientSecret);
                 $client->setRedirectUri((@$_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $this->createUrl(''));
                 $client->setDeveloperKey($admin->googleAPIKey);
                 $client->setAccessType('offline');
                 $googleCalendar = new apiCalendarService($client);
                 if (isset($_GET['code'])) {
                     // returning from google with access token
                     $client->authenticate();
                     $_SESSION['token'] = $client->getAccessToken();
                     header('Location: ' . (@$_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
//.........这里部分代码省略.........
开发者ID:netconstructor,项目名称:X2Engine,代码行数:101,代码来源:DefaultController.php


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