Skip to content

Instantly share code, notes, and snippets.

@fddcddhdd
Last active August 29, 2015 14:26
Show Gist options
  • Save fddcddhdd/640080f32ffaf4e889fe to your computer and use it in GitHub Desktop.
Save fddcddhdd/640080f32ffaf4e889fe to your computer and use it in GitHub Desktop.
Google Contacts(Gmailのアドレス帳) APIのサンプルコード。その1(認証ページへのリンク)
<?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