php Google API的oauth_signature生成

omqzjyyz  于 9个月前  发布在  PHP
关注(0)|答案(1)|浏览(69)

我试图让我的网站的用户的联系人,但我无法从谷歌得到一个令牌,因为我得到无效的oauth签名错误。
如何在PHP中为Google生成oauth签名?

ftf50wuq

ftf50wuq1#

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

$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];
     }
   }
  }

相关问题