本文整理匯總了PHP中Google_Client::setClientid方法的典型用法代碼示例。如果您正苦於以下問題:PHP Google_Client::setClientid方法的具體用法?PHP Google_Client::setClientid怎麽用?PHP Google_Client::setClientid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Google_Client
的用法示例。
在下文中一共展示了Google_Client::setClientid方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: curl
/** I hope you are here by creating google web application, obtaining clientID and client secrete
* if not, got to Google developer console and create app under an API Manager menu
*
*/
session_start();
//include google api library
include 'vendor/autoload.php';
//or wherever autoload.php is located
$google_client_id = 'your Application client ID';
$google_client_secret = 'your client secrete key';
$google_redirect_uri = 'uri to process response form google';
// either self or other php file eg. http://localhost/appname/output.php -- for local machine
//setup new google client
$client = new Google_Client();
$client->setApplicationName('your application name');
$client->setClientid($google_client_id);
$client->setClientSecret($google_client_secret);
$client->setRedirectUri($google_redirect_uri);
$client->setAccessType('online');
$client->setScopes('https://www.google.com/m8/feeds');
$googleImportUrl = $client->createAuthUrl();
// creating a curl function
function curl($url, $post = "")
{
$curl = curl_init();
$userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';
curl_setopt($curl, CURLOPT_URL, $url);
//The URL to fetch. This can also be set when initializing a session with curl_init().
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
//TRUE to return the transfer as a string of the return value of curl_exec() instead of outputting it out directly.
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
示例2: get_drive_client
/**
* @return \Google_Client
*/
public static function get_drive_client()
{
$client = new \Google_Client();
$client->setApplicationName('My WP Backup');
$client->setClientid(base64_decode('ODkwOTA4NDc4NDUzLXNhN3MybHU4ZzVidnBrNXYxMTM2ODJpNmtpdmEyMzEzLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29t'));
$client->setClientSecret(base64_decode('amp6ek04QUxJd0sxTW5DNjJBbDRlUmFG'));
$client->setScopes(array('https://www.googleapis.com/auth/drive'));
$client->setRedirectUri('urn:ietf:wg:oauth:2.0:oob');
$client->setAccessType('offline');
return $client;
}