php 如何从 Magento 1.7 REST API 获取访问令牌和访问令牌秘密

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13263343/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 05:03:59  来源:igfitidea点击:

How to get Access Token and Access Token Secret from Magento 1.7 REST API

phpapimagentorestmagento-1.7

提问by Josua Marcel Chrisano

I've registered my application on my magento admin.

我已经在我的 magento 管理员上注册了我的应用程序。

already got the Consumer Key and Consumer Secret.

已经获得了消费者密钥和消费者秘密。

but i have no luck to get the access token and access token secret.

但我没有运气获得访问令牌和访问令牌秘密。

it said

它说

oauth_problem=parameter_absent&oauth_parameters_absent=oauth_consumer_key

oauth_problem=parameter_absent&oauth_parameters_absent=oauth_consumer_key

Simple REST API

简单的 REST API

i'm testing based on this link

我正在基于此链接进行测试

http://www.magentocommerce.com/api/rest/testing_rest_resources.html

http://www.magentocommerce.com/api/rest/testing_rest_resources.html

What i need to know the answer is

我需要知道的答案是

  1. What must i fill to Header & Data textfield?
  2. How to get the Access Token and Access Secret Token (on Mozilla)?
  3. Is there any tutorial step by step to test any REST API?
  1. 我必须在标题和数据文本字段中填写什么?
  2. 如何获取访问令牌和访问秘密令牌(在 Mozilla 上)?
  3. 是否有任何教程逐步测试任何 REST API?

采纳答案by Josua Marcel Chrisano

0) Install https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjelooto your chrome

0) 将https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo安装到您的 chrome

1) Get an oAuth client tool with command :

1) 使用命令获取 oAuth 客户端工具:

sudo gem install oauth

2) Set up the Magento server

2)设置Magento服务器

3) Get the oAuth tokens

3)获取oAuth令牌

oauth \
  --verbose \
   --query-string \
   --consumer-key v484mnii2jyswedm6uo2cfcjay7uy49snws \
   --consumer-secret koay6845che7giy5lr17gnrhckkbhf8h5 \
   --access-token-url http://www.yourstore.com/magento/oauth/token \
   --authorize-url http://www.yourstore.com/magento/oauth/authorize \
   --request-token-url http://www.yourstore.com/magento/oauth/initiate \
   authorize

RESPOND :

回应 :

Server appears to support OAuth 1.0a; enabling support.
Please visit this url to authorize:
http://www.yourstore.com/magento/oauth/authorize?oauth_token=ey6fokp0pbzwr1016eb528y5xw1ak5ji

Please enter the verification code provided by the SP (oauth_verifier):
YOUR_CODE_HERE

Response:
  oauth_token_secret: g9kyz8c7zv868d58eav1muih3gxvq763
  oauth_token: aqvlfv9tuexn0mqiydgkaff4ixxg8743c

4) Make the API call

4)进行API调用

oauth \
    --consumer-key v484mnii2jyswedm6uo2cfcjay7uy49snws \
    --consumer-secret koay6845che7giy5lr17gnrhckkbhf8h5 \ 
    --token aqvlfv9tuexn0mqiydgkaff4ixxg8743c \
    --secret g9kyz8c7zv868d58eav1muih3gxvq763 \ 
    --uri http://www.yourstore.com/magento/api/rest/products \
    debug

try http://www.yourstore.com/magento/api/rest/products

尝试 http://www.yourstore.com/magento/api/rest/products



Found it the solution

找到了解决方案

http://www.aschroder.com/2012/04/introduction-to-the-magento-rest-apis-with-oauth-in-version-1-7/

http://www.aschroder.com/2012/04/introduction-to-the-magento-rest-apis-with-oauth-in-version-1-7/

for php

用于 php

https://gist.github.com/2469319

https://gist.github.com/2469319