Last active
August 29, 2015 14:26
-
-
Save fddcddhdd/640080f32ffaf4e889fe to your computer and use it in GitHub Desktop.
Google Contacts(Gmailのアドレス帳) APIのサンプルコード。その1(認証ページへのリンク)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// アプリケーション設定 | |
define('CONSUMER_KEY', 'xxxx.apps.googleusercontent.com'); // クライアント ID | |
define('CALLBACK_URL', 'http://xxx.com/contacts/callback.php'); //認証が終ったら戻ってくる自分のページ | |
define('AUTH_URL', 'https://accounts.google.com/o/oauth2/auth'); // Goole側で認証してくれる | |
//-------------------------------------- | |
// 認証ページにリダイレクト | |
//-------------------------------------- | |
$params = array( | |
'client_id' => CONSUMER_KEY, | |
'redirect_uri' => CALLBACK_URL, | |
'scope' => 'https://www.google.com/m8/feeds', | |
'response_type' => 'code', | |
); | |
header("Location: " . AUTH_URL . '?' . http_build_query($params)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment