0
我試圖通過Woocommerce API對AngularJS和Ionic App進行身份驗證。這是我的代碼。Woocommerce API身份驗證錯誤
var ck = 'ck_6fffb5cbc00eqe00a7c3062cd85dae2ee64f919e';
var cs = 'cs_c2fd467cqq8857a08941c15bc708e3c16dc1f026';
var url = 'http://www.mysitecom/wc-api/v3';
var httpMethod = 'GET',
parameters = {
oauth_consumer_key : ck,
oauth_token : '370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb',
oauth_nonce : 'kYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg',
oauth_timestamp : new Date().getTime(),
oauth_signature_method : 'HMAC-SHA1',
oauth_version : '1.0'//,
//file : 'vacation.jpg',
//size : 'original'
},
consumerSecret = cs,
tokenSecret = 'pfkkdhi9sl3r4s00';
var signature = oauthSignature.generate(httpMethod, url, parameters, cs, tokenSecret, { encodeSignature: true });
console.log(signature);
$http.get(url+'/products?oauth_consumer_key='+ck+'&oauth_nonce='+parameters.oauth_nonce+'&oauth_signature='+signature+'&oauth_signature_method=HMAC-SHA1&oauth_timestamp='+parameters.oauth_timestamp+'&oauth_token='+parameters.oauth_token+'oauth_version=1.0').then(function(data){
console.log(data);
}, function(error){
console.log(error);
});
PS:我正在使用this JavaScript庫來生成簽名。
您是否有完整的信息源給我? –