ちょこちょこいじってGmaiの連絡先メールアドレスをLDAPに取り込むPerlスクリプト完成\(^o^)/
なかったのでこんな感じでつくったのだ。
カテゴリーアーカイブ: プログラミング
Google Contacts APIのメモ
Google Contacts APIにアクセスして変換する何かを作ってる途中のメモ。
#Googleアカウントにログイン
$url = 'https://www.google.com/accounts/ClientLogin';
{
%post_data = (
Email => $gdata_user,
Passwd => $gdata_pass,
accountType => 'GOOGLE',
source => 'Google-Contact-Lister',
service => 'cp',
);
$req = POST( $url, [ %post_data ] );
$res = $ua->request( $req );
}
#セッション・承認情報取得
foreach $line ( split( /\n/, $res->content ) ){
( $key, $data ) = split( /=/, $line );
$session->{ $key } = $data;
}
#ログイン成功確認
die "login failed.\n" unless ( $session->{ 'Auth' } );
#Google Contacts APIにアクセス
$index = 1;
$paging = 100;
$url = 'https://www.google.com/m8/feeds/contacts/'.
uri_escape( $gdata_user ).
"/full?start-index=$index&max-results=$paging";
$req = GET( $url );
$req->header(
Authorization => "GoogleLogin auth=$session->{ 'Auth' }",
);
$res = $ua->request( $req );
データは引っ張れるようになったので、次はLDAP。