1

I would like to create mobile app for my magento site for that I have created REST consumer and I got consumer key and consumer secrete.. Then I create rest.php file inside rootdirectory/api/rest. When I call http://localhost/magento/api/rest/ on my postman getting an error like

{"messages": {
"error": [
  {
    "code": 401,
    "message": "oauth_problem=nonce_used"
  }
] }}

What I will do? I am new to magento webservices..

2
  • Maybe this question&answers helps you: stackoverflow.com/questions/15772102/… Commented Jul 27, 2016 at 15:28
  • where I save my php file? Is it in root directory? Commented Jul 28, 2016 at 4:58

1 Answer 1

-1

You can use this PHP file and access in your browser.

<?php
$nonce = substr(md5(uniqid('nonce_', true)),0,16);
$temprealm="http://youmagentostore.com/api/rest/products";
$realm=urlencode($temprealm);
$oauth_version="1.0";
$oauth_signature_method="HMAC-SHA1";
$oauth_consumer_key="ffe7ef1d24dfecdc0e5e31a438b41464R";
$oauth_access_token="gh77390c4322c9fbe58f27e409811cop";
$oauth_method="GET";
$oauth_timestamp=time();
$algo="sha1";
$key="c8e7ef1d24ffecdc0e5e31a438b4146d&8d5e6be3ee69ce8b969594aea61b7cf3"; //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);
$curl = curl_init();



curl_setopt($curl,CURLOPT_HTTPHEADER,array('Authorization : OAuth realm='.$realm.', oauth_version="1.0", oauth_signature_method="HMAC-SHA1", oauth_nonce="'.$nonce.'", oauth_timestamp="'.$oauth_timestamp.'", oauth_consumer_key='.$oauth_consumer_key.', oauth_token='.$oauth_access_token.', oauth_signature="'.$fin_sign.'"'));

curl_setopt ($curl, CURLOPT_URL,$temprealm);
$xml=curl_exec($curl);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.