本文整理汇总了PHP中Google_Client::setClientId方法的典型用法代码示例。如果您正苦于以下问题:PHP Google_Client::setClientId方法的具体用法?PHP Google_Client::setClientId怎么用?PHP Google_Client::setClientId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Google_Client
的用法示例。
在下文中一共展示了Google_Client::setClientId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
include_once AB_PATH . '/lib/google_api_v3/autoload.php';
$this->client = new Google_Client();
$this->client->setClientId(get_option('ab_settings_google_client_id'));
$this->client->setClientSecret(get_option('ab_settings_google_client_secret'));
}
示例2: __construct
public function __construct($oauthClientId, $oauthClientSecret, $oAuthConfig = array())
{
$this->client = new \Google_Client();
$this->client->setClassConfig('Google_Auth_OAuth2', $oAuthConfig);
$this->client->setClientId($oauthClientId);
$this->client->setClientSecret($oauthClientSecret);
}
示例3: __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');
}
示例4: __construct
/**
* @param \Google_Client $client
*/
public function __construct(\Google_Client $client)
{
$this->client = $client;
$this->client->setClientId(\Config::get('google.client_id'));
$this->client->setClientSecret(\Config::get('google.client_secret'));
$this->client->setDeveloperKey(\Config::get('google.api_key'));
$this->client->setRedirectUri(\Config::get('app.url') . "/loginCallback");
$this->client->setScopes(['https://www.googleapis.com/auth/youtube']);
$this->client->setAccessType('offline');
}
示例5: __construct
/**
* Google
* @param $params array - data from config.neon
* @param $cookieName String cookie name
* @param Nette\Http\Response $httpResponse
* @param Nette\Http\Request $httpRequest
*/
public function __construct($params, $cookieName, Nette\Http\Response $httpResponse, Nette\Http\Request $httpRequest)
{
$this->params = $params;
$this->cookieName = $cookieName;
$this->httpResponse = $httpResponse;
$this->httpRequest = $httpRequest;
$this->client = new \Google_Client();
$this->client->setClientId($this->params["clientId"]);
$this->client->setClientSecret($this->params["clientSecret"]);
$this->client->setRedirectUri($this->params["callbackURL"]);
}
示例6: __construct
/**
* Constructor.
*
* @param int $repositoryid repository instance id.
* @param int|stdClass $context a context id or context object.
* @param array $options repository options.
* @param int $readonly indicate this repo is readonly or not.
* @return void
*/
public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array(), $readonly = 0)
{
parent::__construct($repositoryid, $context, $options, $readonly = 0);
$callbackurl = new moodle_url(self::CALLBACKURL);
$this->client = get_google_client();
$this->client->setClientId(get_config('googledocs', 'clientid'));
$this->client->setClientSecret(get_config('googledocs', 'secret'));
$this->client->setScopes(array(Google_Service_Drive::DRIVE_READONLY));
$this->client->setRedirectUri($callbackurl->out(false));
$this->service = new Google_Service_Drive($this->client);
$this->check_login();
}
示例7: __construct
/**
* Constructor.
*
* @param int $repositoryid repository instance id.
* @param int|stdClass $context a context id or context object.
* @param array $options repository options.
* @param int $readonly indicate this repo is readonly or not.
* @return void
*/
public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array(), $readonly = 0)
{
parent::__construct($repositoryid, $context, $options, $readonly = 0);
$callbackurl = new moodle_url(self::CALLBACKURL);
$this->client = new Google_Client();
$this->client->setClientId(get_config('googledocs', 'clientid'));
$this->client->setClientSecret(get_config('googledocs', 'secret'));
$this->client->setScopes(array('https://www.googleapis.com/auth/drive.readonly'));
$this->client->setRedirectUri($callbackurl->out(false));
$this->service = new Google_DriveService($this->client);
$this->check_login();
}
示例8: __construct
/**
* Google
* @param $params array - data from config.neon
* @param $cookieName String cookie name
* @param Nette\Http\Response $httpResponse
* @param Nette\Http\Request $httpRequest
*/
public function __construct($params, $cookieName, Nette\Http\Response $httpResponse, Nette\Http\Request $httpRequest)
{
$this->params = $params;
$this->cookieName = $cookieName;
$this->httpResponse = $httpResponse;
$this->httpRequest = $httpRequest;
$config = new \Google_Config();
$config->setClassConfig('Google_Cache_File', array('directory' => '/temp/cache'));
$this->client = new \Google_Client($config);
$this->client->setClientId($this->params["clientId"]);
$this->client->setClientSecret($this->params["clientSecret"]);
$this->client->setRedirectUri($this->params["callbackURL"]);
}
示例9: 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'));
}
}
示例10: __construct
/**
* Sets the required params for authentication
*
* @param string $client_id our app's client id
* @param string $client_secret our app's client secret
* @param string $redirect_uri where will the auth server send the client
* after generating an authorization code to authenticate
* @param null|string $token token obtained when a code is authenticated
* @param null|string $code response code to authenticate
* @param null|array $scopes array of strings with OAuth2/google scopes
* to requested
* @param null|Google_Client $client
* @param bool $debug defaults to false
*/
public function __construct($client_id, $client_secret, $redirect_uri, $token = null, $code = null, $scopes = null, $client = null, $debug = null)
{
$this->client_id = $client_id;
$this->client_secret = $client_secret;
$this->redirect_uri = $redirect_uri;
$this->code = $code;
$this->token = $token;
if ($scopes !== null) {
$this->scopes = $scopes;
}
if (is_bool($this->debug)) {
$this->debug = $debug;
} else {
$this->debug = false;
}
if ($client === null) {
$this->client = new Google_Client();
$this->client->setClientId($this->client_id);
$this->client->setClientSecret($this->client_secret);
$this->client->setRedirectUri($this->redirect_uri);
if ($token !== null) {
$this->client->setAccessToken($token);
}
$this->client->setScopes($this->scopes);
}
}
示例11: googleCallbackAction
public function googleCallbackAction()
{
$response = array("status" => 0, "message" => "Thao tác không thành công");
$code = $this->request->getPost("code", null, false);
if ($code) {
$google = new \Google_Client();
$google->setApplicationName($this->config["GOOGLE_NAME"]);
$google->setClientId($this->config["GOOGLE_ID"]);
$google->setClientSecret($this->config["GOOGLE_SECRET"]);
$google->setRedirectUri('postmessage');
$scopes = array("https://www.googleapis.com/auth/userinfo.profile", "https://www.googleapis.com/auth/userinfo.email");
$google->setScopes($scopes);
$google->authenticate($code);
$request = new \Google_Http_Request("https://www.googleapis.com/oauth2/v2/userinfo?alt=json");
$userinfo = $google->getAuth()->authenticatedRequest($request);
$response = $userinfo->getResponseBody();
$userinfo = json_decode($response, true);
$id = $userinfo["id"];
$username = explode("@", $userinfo["email"]);
$username = $username[0] . "_gg_" . $id;
$data_user = array("email" => $userinfo["email"], "nickname" => $userinfo["name"], "username" => $username, "id" => $id);
$response = $this->doSocialLogin($data_user);
}
echo json_encode($response);
exit;
}
示例12: call_back
public function call_back()
{
$config = new Controllers_Api_Google_Config_App();
$client = new Google_Client();
$client->setClientId($config->config['client_id']);
$client->setClientSecret($config->config['client_secret']);
$client->setRedirectUri($config->config['redirect_uri']);
$client->addScope("email");
$client->addScope("profile");
$service = new Google_Service_Oauth2($client);
if (isset($_GET['code'])) {
$client->authenticate($_GET['code']);
$_SESSION['access_token'] = $client->getAccessToken();
header('Location: ' . filter_var($config->config['redirect_uri'], FILTER_SANITIZE_URL));
exit;
}
/************************************************
If we have an access token, we can make
requests, else we generate an authentication URL.
************************************************/
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
$client->setAccessToken($_SESSION['access_token']);
} else {
$authUrl = $client->createAuthUrl();
}
if (isset($authUrl)) {
//show login url
echo json_encode(array('status' => false, 'data' => $authUrl));
} else {
$user = $service->userinfo->get();
//get user info
echo json_encode(array('status' => true, 'data' => $user));
}
}
示例13: authorizeGoogleUser
function authorizeGoogleUser($access_code)
{
$client = new \Google_Client();
$google = $this->config->google;
$client->setApplicationName('Portal da Rede');
$client->setClientId($google->clientId);
$client->setClientSecret($google->secret);
$client->setRedirectUri('postmessage');
$client->addScope('https://www.googleapis.com/auth/userinfo.profile');
$client->addScope('https://www.googleapis.com/auth/userinfo.email');
$client->authenticate($access_code);
$json_token = $client->getAccessToken();
$client->setAccessToken($json_token);
$plus = new \Google_Service_Plus($client);
$user = $plus->people->get('me');
if (!$user->emails || !is_array($user->emails)) {
return;
}
$email = $user->emails[0]['value'];
$user_email = $this->db->user_email->find_one($email);
if (!$user_email) {
return;
}
$this->login($user_email->user);
}
示例14: 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;
}
示例15: createClient
private function createClient()
{
$options = ['auth' => 'google_auth', 'exceptions' => false];
if ($proxy = getenv('HTTP_PROXY')) {
$options['proxy'] = $proxy;
$options['verify'] = false;
}
// adjust constructor depending on guzzle version
if (!$this->isGuzzle6()) {
$options = ['defaults' => $options];
}
$httpClient = new GuzzleHttp\Client($options);
$client = new Google_Client();
$client->setApplicationName('google-api-php-client-tests');
$client->setHttpClient($httpClient);
$client->setScopes(["https://www.googleapis.com/auth/plus.me", "https://www.googleapis.com/auth/urlshortener", "https://www.googleapis.com/auth/tasks", "https://www.googleapis.com/auth/adsense", "https://www.googleapis.com/auth/youtube", "https://www.googleapis.com/auth/drive"]);
if ($this->key) {
$client->setDeveloperKey($this->key);
}
list($clientId, $clientSecret) = $this->getClientIdAndSecret();
$client->setClientId($clientId);
$client->setClientSecret($clientSecret);
$client->setCache($this->getCache());
return $client;
}