本文整理汇总了PHP中apiClient::setApprovalPrompt方法的典型用法代码示例。如果您正苦于以下问题:PHP apiClient::setApprovalPrompt方法的具体用法?PHP apiClient::setApprovalPrompt怎么用?PHP apiClient::setApprovalPrompt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apiClient
的用法示例。
在下文中一共展示了apiClient::setApprovalPrompt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例2: explode
$cookie = explode('+', $_COOKIE['hexauser']);
if (empty($cookie) || count($cookie) < 2) {
setcookie('hexauser', '', time() - 60 * 60 * 24 * 365, '/', $_SERVER['HTTP_HOST']);
echo json_encode(array('status' => 'error', 'message' => 'incomplete session'));
exit;
}
$userId = $cookie[0];
$sessionId = $cookie[1];
require_once '../libs/google/apiClient.php';
//require_once '../libs/google/contrib/apiOauth2Service.php';
$client = new apiClient();
$client->setApplicationName('Hexagame');
$client->setClientId($config['googleId']);
$client->setClientSecret($config['googleSecret']);
$client->setRedirectUri($config['googleRedirect']);
$client->setApprovalPrompt('auto');
//$oauth2 = new apiOauth2Service($client);
$db = new PDO($config['db'], $config['dbUser'], $config['dbPassword']);
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
$stmt = $db->prepare("SELECT `name`, `email`, `token` FROM `users`, `sessions` WHERE `sessions`.`user_id` = `users`.`id` AND `sessions`.`id` = :sessionId AND `users`.`id` = :userId LIMIT 1");
$stmt->execute(array(':userId' => $userId, ':sessionId' => $sessionId));
$user = $stmt->fetch();
if (!$user) {
setcookie('hexauser', '', time() - 60 * 60 * 24 * 365, '/', $_SERVER['HTTP_HOST']);
echo json_encode(array('status' => 'error', 'message' => 'wrong session'));
exit;
}
$token = $user->token;
$client->setAccessToken($token);
$token = $client->getAccessToken();
if (!$token) {
示例3: test_goog
public function test_goog()
{
$accessToken = '{"access_token":"ya29.AHES6ZQ9yjVf6xdFjpiLZsfqQIAxDOkm95MMv33GHySZlYNRpsgPrA","token_type":"Bearer","expires_in":3600,"refresh_token":"1\\/-qDO6Ug3qj_xnlCqMdhJ0N0zD8QxpZFBI5tFhJtOark","created":1342628689}';
App::import("Vendor", "GoogleApiClient", array("file" => "google-api-php-client/src/apiClient.php"));
App::import("Vendor", "GoogleBigqueryApi", array("file" => "google-api-php-client/src/contrib/apiBigqueryService.php"));
$apiClient = new apiClient();
$apiClient->setApplicationName("Testing App");
$apiClient->setClientId("632632109626-oi3e0cvvkbur75r1fe4cg80dbuk4sjds@developer.gserviceaccount.com");
$apiClient->setClientSecret("dhWNmyamq9LPLfMpWStQbmww");
$apiClient->setRedirectUri("http://" . $_SERVER['HTTP_HOST'] . "/tester/goog_callback");
$apiClient->setScopes(array('https://www.googleapis.com/auth/bigquery'));
$apiClient->setApprovalPrompt("auto");
$apiClient->setAccessToken($accessToken);
$bq = new apiBigqueryService($apiClient);
die(pr($bq->jobs->getQueryResults("theberrics.com:site-reports", "job_d6238b593ead456f9c8cffa0c1ea2e56")));
die(pr($bq->jobs->get("theberrics.com:site-reports", "job_d6238b593ead456f9c8cffa0c1ea2e56")));
}
示例4: apiClient
<?php
// Create a new Google API client
$client = new apiClient();
//$client->setApplicationName("Tutorialzine");
// Configure it
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setDeveloperKey($api_key);
$client->setRedirectUri($redirect_url);
$client->setApprovalPrompt(false);
$oauth2 = new apiOauth2Service($client);
// The code parameter signifies that this is
// a redirect from google, bearing a temporary code
if (isset($_GET['code'])) {
// This method will obtain the actuall access token from Google,
// so we can request user info
$client->authenticate();
// Get the user data
$info = $oauth2->userinfo->get();
// Find this person in the database
$person = ORM::for_table('glogin_users')->where('email', $info['email'])->find_one();
if (!$person) {
// No such person was found. Register!
$person = ORM::for_table('glogin_users')->create();
// Set the properties that are to be inserted in the db
$person->email = $info['email'];
$person->name = $info['name'];
if (isset($info['picture'])) {
// If the user has set a public google account photo
$person->photo = $info['picture'];
示例5: index
public function index()
{
$this->load->language('easycheck/auth');
$data['text_heading'] = $this->language->get('text_heading');
$data['text_describe'] = $this->language->get('text_describe');
$data['text_savetime'] = $this->language->get('text_savetime');
$data['text_reg_log'] = $this->language->get('text_reg_log');
$data['text_proceedguest'] = $this->language->get('text_proceedguest');
$data['text_guest'] = $this->language->get('text_guest');
$data['text_or'] = $this->language->get('text_or');
$data['btn_continue'] = $this->language->get('btn_continue');
$data['btn_facebook'] = $this->language->get('btn_facebook');
$data['btn_gplus'] = $this->language->get('btn_gplus');
$data['input_email'] = $this->language->get('input_email');
$data['input_passd'] = $this->language->get('input_passd');
$data['check_availability'] = $this->url->link('easycheck/auth/check_availability');
$data['login'] = $this->url->link('easycheck/auth/login');
$data['guest_login'] = $this->url->link('easycheck/auth/guest_login');
$data['address_url'] = $this->url->link('easycheck/address');
$data['cant_access'] = $this->language->get('cant_access');
$data['forgot_password'] = $this->url->link('account/forgotten', '', 'SSL');
///////////////////////facebook & google login start////////////////////////////////
$appId = $this->settings['step']['facebook_login']['app_id'];
$secret = $this->settings['step']['facebook_login']['app_secret'];
$data['appId'] = $appId;
$data['secret'] = $secret;
//google login settings
$this->load->library('googleSetup');
$client = new apiClient();
$redirect_url = HTTP_SERVER . 'index.php?route=easycheck/checkout';
$client->setClientId('702107489335-fsutq69eq4turib43ksldj8t59dsckul.apps.googleusercontent.com');
$client->setClientSecret('vvNUGsKFe3_pA8aK4w-LysBS');
$client->setDeveloperKey('702107489335-fsutq69eq4turib43ksldj8t59dsckul.apps.googleusercontent.com');
$client->setRedirectUri($redirect_url);
$client->setApprovalPrompt(false);
$oauth2 = new apiOauth2Service($client);
$data['client'] = $client;
$url = $client->createAuthUrl();
$data['url'] = $url;
if (isset($this->request->get['code'])) {
$client->authenticate();
$info = $oauth2->userinfo->get();
if (isset($info['given_name']) && $info['given_name'] != "") {
$name = $info['given_name'];
} else {
$name = $info['name'];
}
$user_table = array('firstname' => $name, 'lastname' => $info['family_name'], 'email' => $info['email'], 'telephone' => '', 'fax' => '', 'password' => substr(md5(uniqid(rand(), true)), 0, 9), 'company' => '', 'company_id' => '', 'tax_id' => '', 'address_1' => '', 'address_2' => '', 'city' => '', 'postcode' => '', 'country_id' => '', 'zone_id' => '', 'customer_group_id' => 1, 'status' => 1, 'approved' => 1);
$this->load->model('account/customer');
//getting customer info if already exists
$users_check = $this->model_account_customer->getCustomerByEmail($info['email']);
//adding customer if new
if (empty($users_check)) {
$this->model_account_customer->addFacebookGoogleCustomer($user_table);
}
$users_check = $this->model_account_customer->getCustomerByEmail($info['email']);
//loging in the customer
$users_pass = $this->customer->login($info['email'], '', true);
$this->session->data['customer_id'] = $users_check['customer_id'];
if ($users_pass == true) {
echo '<script>window.opener.location.href ="' . $redirect_url . '"; window.close();</script>';
} else {
echo '<script>window.opener.location.href ="' . $redirect_url . '"; window.close();</script>';
}
}
///////////////////////facebook & google login start////////////////////////////////
unset($this->session->data['guest']);
unset($this->session->data['payment_address']);
unset($this->session->data['shipping_address']);
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/easycheck/auth.tpl')) {
return $this->load->view($this->config->get('config_template') . '/template/easycheck/auth.tpl', $data);
}
}