簡體   English   中英

無法在iPhone中訪問magento REST API

[英]magento REST API not accessible in iphone

當我嘗試使用iPhone訪問rest API時,我已在URL中傳遞了以下參數,並同時使用了POSTGET方法,但顯示Access Denied

oauth_version="1.0", 
oauth_signature_method="HMAC-SHA1",
oauth_nonce="B0dlzkfMWCAn0TJ", 
oauth_timestamp="1366280813",
oauth_consumer_key="klkjylsiozbv6vfdsqtuheqo3kmqqzv2",
oauth_token="t9pefrwylmg7webyepsqepotlhzbytkp",
oauth_signature="NeOwbCLUPbIyF9ErnHoFQOl9%2Bwo%3D"

我已經使用了適用於Firefox和Chrome的REST Client插件,REST API使用REST Client插件可以很好地工作,但無法在iPhone中訪問。

我正在為oauth_timestamp,oauth_signature和oauth_nonce生成一個隨機值,然后REST API也會顯示Access Denied

請提供建議。

//此處final_sign是從以下過程生成的簽名。

$nonce = substr(md5(uniqid('nonce_', true)),0,16);
$temprealm="http://magentohost/api/rest/products";
$realm=urlencode($temprealm);
$oauth_version="1.0";
$oauth_signature_method="HMAC-SHA1";
$oauth_consumer_key="dfddfgdgdfgddf6qgygmyvw7e3";
$oauth_access_token="fdgdfgfdgdfg357gimpdnuejvcbtk51ni";
$oauth_method="GET";
$oauth_timestamp=time();
$algo="sha1";
$key="sb88hfdihyg25ipt1by559yzbj2m3861&s7uhaheu8nrx961oxg6uc3os4zgyc2tm"; //consumer secret & token secret //Both are used in generate signature
$data="oauth_consumer_key=".$oauth_consumer_key."&oauth_nonce=".$nonce."&oauth_signature_method=".$oauth_signature_method."&oauth_timestamp=".$oauth_timestamp."&oauth_token=".$oauth_access_token."&oauth_version=".$oauth_version;

$send_data=$oauth_method."&".$realm."&".urlencode($data);
$sign=hash_hmac($algo,$send_data,$key,1); // consumer key and token secrat used here
$fin_sign=base64_encode($sign);

echo $fin_sign;

根據您的問題,我了解到您對簽名隨機數使用了隨機值。 后者會很好,但是隨機簽名會使接收者不信任您作為合法客戶。

因此,實際上,您得到了請求的響應(;-))。 但這不能解決您的問題。

您必須為magento系統生成有效的簽名

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM