oauth_signature generation for Google API
I am trying to get the contacts of user for my website, but I am not able to get a token from google because i am getting invalid oauth signature error. Can anyone tell me how to generate an oauth signature in PHP f开发者_运维知识库or google.
Thanks :)
this is how I did for getting data from google analytics
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://www.google.com/accounts/ClientLogin');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_POST, TRUE);
$data = array(
'accountType' => 'GOOGLE',
'Email' => $email, //your google email
'Passwd' => $password, //your google pass
'service' => 'analytics',
'source' => 'curl-accountFeed-v2'
);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($curl);
$info = curl_getinfo($curl);
curl_close($curl);
if ($info['http_code'] == 200) {
if ($response) {
preg_match('/Auth=(.*)/', $response, $matches);
if (isset($matches[1])) {
$auth_code = $matches[1];
}
}
}
精彩评论