Reputation: 3793
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.
How to generate an oauth signature in PHP for google?
Upvotes: 0
Views: 345
Reputation: 6656
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];
}
}
}
Upvotes: 1