本文整理汇总了PHP中Google_Client::getClientId方法的典型用法代码示例。如果您正苦于以下问题:PHP Google_Client::getClientId方法的具体用法?PHP Google_Client::getClientId怎么用?PHP Google_Client::getClientId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Google_Client
的用法示例。
在下文中一共展示了Google_Client::getClientId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onSignIn
$state = sha1(uniqid(mt_rand(), true));
$_SESSION['state'] = $state;
// Render the Google+ sign-in button.
print <<<MARKUP
<!doctype html><html><head>
<script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>
<script type="text/javascript">
// The simplest possible solution to this callback. In your application,
// you would want to replace the button with markup that indicates the state.
function onSignIn() {
window.location.reload(true);
}
</script></head>
<body>
<g:plus action="connect"
clientid="{$client->getClientId()}"
redirecturi="{$client->getRedirectUri()}"
scope="https://www.googleapis.com/auth/plus.moments.write"
state="{$state}" callback="onSignIn">
</g:plus></body></html>
MARKUP;
} else {
// Build the moment to write
$target = new Google_ItemScope();
$target->url = 'https://developers.google.com/+/plugins/snippet/examples/thing';
$moment = new Google_Moment();
$moment->type = "http://schemas.google.com/AddActivity";
$moment->target = $target;
// Execute the request
$moments->moments->insert('me', 'vault', $moment);
print '<p>Created an AddActivity moment</p>';
示例2: dirname
}
if (isset($_SESSION[$sessTokenKey]) && isset($_SESSION[$sessTokenKey]['access_token'])) {
$client->setAccessToken($_SESSION[$sessTokenKey]);
}
}
}
xoops_cp_header();
include dirname(__FILE__) . '/mymenu.php';
echo '<h3>' . xelfinderAdminLang('GOOGLEDRIVE_GET_TOKEN') . '</h3>';
if ($php54up) {
$form = true;
if ($client) {
if (empty($_POST) && $client->getAccessToken()) {
try {
$aToken = $client->getAccessToken();
$token = array('client_id' => $client->getClientId(), 'client_secret' => $client->getClientSecret(), 'access_token' => $aToken['access_token']);
if (isset($aToken['refresh_token'])) {
unset($token['access_token']);
$token['refresh_token'] = $aToken['refresh_token'];
}
$ext_token = json_encode($token);
echo '<h3>Google Drive API Token</h3>';
echo '<div><textarea class="allselect" style="width:70%;height:5em;" spellcheck="false">' . $ext_token . '</textarea></div>';
echo '<h3>Example to Volume Driver Setting</h3>';
echo '<div><p>Folder ID as root: <input type=text id="xelfinder_googledrive_folder" value="root"></input> "root" is <a href="https://drive.google.com/drive/my-drive" target="_blank">"My Drive" of your Google Drive</a>.</p>';
echo '<p>You can find the folder ID to the URL(folders/[Folder ID]) of the site of <a href="https://drive.google.com/drive/">GoogleDrive</a>.</p></div>';
echo '<div><textarea class="allselect" style="width:70%;height:7em;" id="xelfinder_googledrive_volconf" spellcheck="false">xelfinder:flyGoogleDrive:root:GoogleDrive:gid=1|id=gd|ext_token=' . $ext_token . '</textarea></div>';
echo "<script>(function(\$){\n\t\t\t\t\t\$('#xelfinder_googledrive_folder').on('change keyup mouseup paste', function(e) {\n\t\t\t\t\t\tvar self = \$(this);\n\t\t\t\t\t\tsetTimeout(function(){\n\t\t\t\t\t\t\tvar conf = \$('#xelfinder_googledrive_volconf');\n\t\t\t\t\t\t\t\tdata = conf.val();\n\t\t\t\t\t\t\tconf.val(data.replace(/flyGoogleDrive:[^:]*:/, 'flyGoogleDrive:' + self.val() + ':'));\n\t\t\t\t\t\t}, e.type === 'paste'? 100 : 0);\n\t\t\t\t\t});\n\t\t\t\t\t\$('textarea.allselect').on('focus', function() { \$(this).select(); });\n\t\t\t\t})(jQuery);</script>";
echo '<h4><a href="' . $selfURL . '&start">Reauthorization</a></h4>';
$form = false;
} catch (Google_Exception $e) {
示例3: testJsonConfig
public function testJsonConfig()
{
// Device config
$client = new Google_Client();
$device = '{"installed":{"auth_uri":"https://accounts.google.com/o/oauth2/auth","client_secret"' . ':"N0aHCBT1qX1VAcF5J1pJAn6S","token_uri":"https://accounts.google.com/o/oauth2/token",' . '"client_email":"","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","oob"],"client_x509_cert_url"' . ':"","client_id":"123456789.apps.googleusercontent.com","auth_provider_x509_cert_url":' . '"https://www.googleapis.com/oauth2/v1/certs"}}';
$dObj = json_decode($device, true);
$client->setAuthConfig($dObj);
$this->assertEquals($client->getClientId(), $dObj['installed']['client_id']);
$this->assertEquals($client->getClientSecret(), $dObj['installed']['client_secret']);
$this->assertEquals($client->getRedirectUri(), $dObj['installed']['redirect_uris'][0]);
// Web config
$client = new Google_Client();
$web = '{"web":{"auth_uri":"https://accounts.google.com/o/oauth2/auth","client_secret"' . ':"lpoubuib8bj-Fmke_YhhyHGgXc","token_uri":"https://accounts.google.com/o/oauth2/token"' . ',"client_email":"123456789@developer.gserviceaccount.com","client_x509_cert_url":' . '"https://www.googleapis.com/robot/v1/metadata/x509/123456789@developer.gserviceaccount.com"' . ',"client_id":"123456789.apps.googleusercontent.com","auth_provider_x509_cert_url":' . '"https://www.googleapis.com/oauth2/v1/certs"}}';
$wObj = json_decode($web, true);
$client->setAuthConfig($wObj);
$this->assertEquals($client->getClientId(), $wObj['web']['client_id']);
$this->assertEquals($client->getClientSecret(), $wObj['web']['client_secret']);
$this->assertEquals($client->getRedirectUri(), '');
}