<legend id='XBMm5'><style id='XBMm5'><dir id='XBMm5'><q id='XBMm5'></q></dir></style></legend>

      <tfoot id='XBMm5'></tfoot>

      <i id='XBMm5'><tr id='XBMm5'><dt id='XBMm5'><q id='XBMm5'><span id='XBMm5'><b id='XBMm5'><form id='XBMm5'><ins id='XBMm5'></ins><ul id='XBMm5'></ul><sub id='XBMm5'></sub></form><legend id='XBMm5'></legend><bdo id='XBMm5'><pre id='XBMm5'><center id='XBMm5'></center></pre></bdo></b><th id='XBMm5'></th></span></q></dt></tr></i><div id='XBMm5'><tfoot id='XBMm5'></tfoot><dl id='XBMm5'><fieldset id='XBMm5'></fieldset></dl></div>
    1. <small id='XBMm5'></small><noframes id='XBMm5'>

          <bdo id='XBMm5'></bdo><ul id='XBMm5'></ul>
      1. PHP Oauth 签名_无效

        PHP Oauth signature_invalid(PHP Oauth 签名_无效)
        • <legend id='qCYZS'><style id='qCYZS'><dir id='qCYZS'><q id='qCYZS'></q></dir></style></legend>

              <bdo id='qCYZS'></bdo><ul id='qCYZS'></ul>

                <i id='qCYZS'><tr id='qCYZS'><dt id='qCYZS'><q id='qCYZS'><span id='qCYZS'><b id='qCYZS'><form id='qCYZS'><ins id='qCYZS'></ins><ul id='qCYZS'></ul><sub id='qCYZS'></sub></form><legend id='qCYZS'></legend><bdo id='qCYZS'><pre id='qCYZS'><center id='qCYZS'></center></pre></bdo></b><th id='qCYZS'></th></span></q></dt></tr></i><div id='qCYZS'><tfoot id='qCYZS'></tfoot><dl id='qCYZS'><fieldset id='qCYZS'></fieldset></dl></div>

                • <small id='qCYZS'></small><noframes id='qCYZS'>

                • <tfoot id='qCYZS'></tfoot>
                    <tbody id='qCYZS'></tbody>
                  本文介绍了PHP Oauth 签名_无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我无法理解为什么这行不通……我真的认为应该如此.请帮忙.

                  I can't wrap my brain around why this isn't work... I really think it should be. Please help.

                  这是我得到的错误:

                  signature_invalid base_string:GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_callback%3Dhttp%253A%252F%252Fnoweis.net%252Fauthsub%252Fauthsub%252Fauthsub%252Fauthsub%252Fauthsub%252Fauthsub%252Fauthsub%252Fauthsub%252Fauindex.php%CONsumeruthauthkey%26othauthkey_consumer%2Faccounts%2FOAuthGetRequestToken&oauth_callback%3Dhttp%253A%252F%252Fnoweis3D3bafa031c03f6d1590f2539091245270%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1282159845%26oauth_version%3D1.0%225www%2Futh%225www%2Fapi>225www%2F%2F%2Futh%2Futh%2Futh%2Futh%2F%2Futh%2Fu

                  signature_invalid base_string:GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_callback%3Dhttp%253A%252F%252Fnoveis.net%252Fauthsub%252Findex.php%26oauth_consumer_key%CONSUMER KEY HERE%26oauth_nonce%3D3bafa031c03f6d1590f2539091245270%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1282159845%26oauth_version%3D1.0%26scope%3Dhttps%253A%252F%252Fwww.googleapis.com%252Fauth%252Flatitude

                  这是我的代码:

                  <?php
                  
                  $consumer = ''; // Would be consumer key
                  $secret = ''; // Would be secret
                  $callback = ''; // Would be callback URL
                  
                  $mt = microtime();
                  $rand = mt_rand();
                  $nonce = md5($mt . $rand);
                  $time = time();
                  
                  $url = 'https://www.google.com/accounts/OAuthGetRequestToken';
                  $path = '/accounts/OAuthGetRequestToken';
                  
                  $scope = 'https://www.googleapis.com/auth/latitude';
                  
                  $post = array(
                      'oauth_callback' => $callback,
                      'oauth_consumer_key' => $consumer,
                      'oauth_nonce' => $nonce,
                      'oauth_signature_method' => 'HMAC-SHA1',
                      'oauth_timestamp' => $time,
                      'oauth_version' => '1.0'
                  );
                  
                  $post_string = '';
                  foreach ($post as $key => $value) {
                      $post_string .= $key . '=' . urlencode($value) . '&';
                  }
                  $post_string = rtrim($post_string, '&');
                  
                  $key_parts = array($consumer, $secret);
                  
                  $key_parts = array_map('urlencode', $key_parts);
                  $key = implode('&', $key_parts);
                  
                  $base_string = 'GET&' . urlencode($scope) . '&' . $post_string;
                  $signature = base64_encode(hash_hmac('sha1', $base_string, $key, true));
                  $post['oauth_signature'] = $signature;
                  $header_string = '';
                  foreach ($post as $key => $value) {
                      $header_string .= $key . '="' . urlencode($value) . '", ';
                  }
                  $header_string = trim($header_string);
                  $header_string = rtrim($header_string, ',');
                  
                  $header[] = 'GET ' . $path . '?scope=' . urlencode($scope) . ' HTTP/1.1';
                  $header[] = 'Host: www.google.com';
                  $header[] = 'Accept: */*';
                  //$header[] = 'Content-Type: application/x-www-form-urlencoded';
                  $header[] = 'Authorization: OAuth ' . $header_string;
                  $ch = curl_init();
                  curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
                  curl_setopt($ch, CURLOPT_URL, $url . '?scope=' . $scope);
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
                  $result = curl_exec($ch);
                  curl_close($ch);
                  print_r($result);
                  ?>
                  

                  推荐答案

                  好吧,我自己解决了问题.我一行一行,一点一点地经历了这一切,我明白了.问题是我正在做我的消费者 &签名的秘密,当它应该只是我的秘密时,然后是授权标头中应该存在的差异与签名中需要的差异.

                  Well, I solved my own problem. I went through this line by line, bit by bit and I got it. The problems were I was doing my consumer & secret to sign, when it should have been just my secret, and then it was the differences that should be in the Authorization header compared to what needs to be in the signature.

                  这是我的代码,如果它可以帮助其他人:

                  Here is my code if it'll help anyone else:

                  $consumer = '';
                  $secret = '';
                  $callback = '';
                  $sign_method = 'HMAC-SHA1';
                  $version = '1.0';
                  $scope = 'https://www.googleapis.com/auth/latitude';
                  
                  function urlencodeRFC3986($string)
                  {
                     return str_replace('%7E', '~', rawurlencode($string));
                  }
                  
                  
                  $mt = microtime();
                  $rand = mt_rand();
                  $nonce = md5($mt.$rand);
                  $time = time();
                  
                  $url = 'https://www.google.com/accounts/OAuthGetRequestToken';
                  $path = '/accounts/OAuthGetRequestToken';
                  
                  $post = array(
                      'oauth_callback' => urlencodeRFC3986($callback),
                      'oauth_consumer_key' => $consumer,
                      'oauth_nonce' => $nonce,
                      'oauth_signature_method' => $sign_method,
                      'oauth_timestamp' => $time,
                      'oauth_version' => $version,
                      'scope' => urlencodeRFC3986($scope)
                  );
                  
                  $post_string = '';
                  foreach($post as $key => $value)
                  {
                      $post_string .= $key.'='.($value).'&';
                  }
                  $post_string = rtrim($post_string, '&');
                  
                  $key_parts = array($secret);
                  
                  $key_parts = urlencodeRFC3986($secret);
                  //$key = implode('&', $key_parts);
                  $key = $key_parts.'&';
                  $base_string = 'GET&'.urlencodeRFC3986($url).'&'.urlencodeRFC3986($post_string);
                  $signature = base64_encode(hash_hmac('sha1', $base_string, $key, true));
                  
                  
                  $post = array(
                      'oauth_version' => $version,
                      'oauth_nonce' => $nonce,
                      'oauth_timestamp' => $time,
                      'oauth_consumer_key' => $consumer,
                      'oauth_callback' => $callback,
                      'oauth_signature_method' => $sign_method,
                      'oauth_signature' => $signature
                  );        
                  
                  $header_string = '';
                  foreach($post as $key => $value)
                  {
                      $header_string .= $key.'="'.urlencodeRFC3986($value).'", ';
                  }
                  
                  $header_string = trim($header_string);
                  $header_string = rtrim($header_string, ',');
                  
                  $header[] = 'GET '.$path.'?scope='.urlencodeRFC3986($scope).' HTTP/1.1';
                  $header[] = 'Host: www.google.com';
                  $header[] = 'Accept: */*';
                  //$header[] = 'Content-Type: application/x-www-form-urlencoded';
                  $header[] = 'Authorization: OAuth '.$header_string;
                  
                  
                  $ch = curl_init();
                  curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
                  curl_setopt($ch, CURLOPT_URL, $url.'?scope='.$scope);
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
                  $result = curl_exec($ch);
                  curl_close($ch);
                  print_r($result);
                  die();
                  ?>
                  

                  这篇关于PHP Oauth 签名_无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  <tfoot id='x4oYW'></tfoot>

                          <bdo id='x4oYW'></bdo><ul id='x4oYW'></ul>
                            <tbody id='x4oYW'></tbody>
                        • <small id='x4oYW'></small><noframes id='x4oYW'>

                          <i id='x4oYW'><tr id='x4oYW'><dt id='x4oYW'><q id='x4oYW'><span id='x4oYW'><b id='x4oYW'><form id='x4oYW'><ins id='x4oYW'></ins><ul id='x4oYW'></ul><sub id='x4oYW'></sub></form><legend id='x4oYW'></legend><bdo id='x4oYW'><pre id='x4oYW'><center id='x4oYW'></center></pre></bdo></b><th id='x4oYW'></th></span></q></dt></tr></i><div id='x4oYW'><tfoot id='x4oYW'></tfoot><dl id='x4oYW'><fieldset id='x4oYW'></fieldset></dl></div>
                          <legend id='x4oYW'><style id='x4oYW'><dir id='x4oYW'><q id='x4oYW'></q></dir></style></legend>