Google API 的 oauth_signature 生成

问题描述 投票:0回答:1

我正在尝试获取我网站的用户联系人,但我无法从 Google 获取令牌,因为我收到无效的 oauth 签名错误。

如何在 PHP 中为 google 生成 oauth 签名?

php oauth google-api
1个回答
1
投票

这就是我从谷歌分析获取数据的方法

  $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];
     }
   }
  }
© www.soinside.com 2019 - 2024. All rights reserved.