OAuth1.0无效的woocommerce api签名

时间:2016-07-12 07:15:03

标签: php android oauth woocommerce-rest-api

我按照一步一步wc_api_docs进行了对oauth1.0a单边验证的身份验证,但我的代码在php或java中的签名与postmans签名不同,我面对这个错误:

  

{“code”:“woocommerce_rest_authentication_error”,
  “信息”:   “签名无效 - 提供的签名不匹配。”,
  “数据”:{       “状态”:401}}

$url = rawurlencode("http://localhost/wordpress/wordpress/wp-json/wc/v1/products");
$ck = rawurlencode("oauth_consumer_key").'='.rawurlencode("ck_s6ec05447691a63c76b3ffc575f2f29ba7c0438c");
$nonce = rawurlencode("oauth_nonce").'='.rawurlencode("zNebTNK");
$timestamp = rawurlencode("oauth_timestamp").'='.rawurlencode("1468302526");
$s_method = rawurlencode("oauth_signature_method").'='.rawurlencode("HMAC-SHA256");


$params = rawurlencode($ck."&".$nonce."&".$s_method."&".$timestamp);
$http_method = "GET";

$signature_base = $http_method."&".$url."&".$params;
echo $signature_base.'-------------';
$s = hash_hmac('sha256', $signature_base, 'cs_s70ac550670bdf16e72213855c9745518320e68c', true);
echo urlencode(base64_encode($s));

并且我无法生成正确的签名,但我的邮递员使用此值可正常工作!

0 个答案:

没有答案
相关问题