Magento Rest API-oAuth错误 [英] Magento Rest API - oAuth Error

查看:50
本文介绍了Magento Rest API-oAuth错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次使用Magento Rest API,我在 http://www.magentocommerce.com/api/rest 上浏览了Rest API的教程,并尝试了一个示例来获取通过API的产品:

I am working with Magento Rest API for the first time, i went through the tutorials of Rest API on http://www.magentocommerce.com/api/rest and tried one example to fetch product through API:

$callbackUrl = "http://localhost/wineshop/products.php";
$temporaryCredentialsRequestUrl = "http://localhost/wineshop/oauth/initiate?     oauth_callback=" . urlencode($callbackUrl);
$adminAuthorizationUrl = 'http://localhost/wineshop/admin/oauth_authorize';
$accessTokenRequestUrl = 'http://localhost/wineshop/oauth/token';
$apiUrl = 'http://localhost/wineshop/api/rest';
$consumerKey = 'u48p1x9gzrg7r82c94woa5z7g805uw0i';
$consumerSecret = '96ydrk8s89xxath8h5z71vcl5abfq0zg';

session_start();
if (!isset($_GET['oauth_token']) && isset($_SESSION['state']) && $_SESSION['state'] == 1) {
$_SESSION['state'] = 0;
}
try {
$authType = ($_SESSION['state'] == 2) ? OAUTH_AUTH_TYPE_AUTHORIZATION : OAUTH_AUTH_TYPE_URI;
$oauthClient = new OAuth($consumerKey, $consumerSecret,  OAUTH_SIG_METHOD_HMACSHA1, $authType);
$oauthClient->enableDebug();

我还安装了最新版本的OAUTH,它也显示在我的WampServer PHP扩展中,但未显示在 phpinfo()中.我将 php_oauth.dll 文件复制到 .. \ www \ bin \ php \ ext 中,还编辑了 php.ini 并输入了 extension = php_oauth.dll ,但是在运行 products.php 时,它向我显示

I've also installed the latest version of OAUTH and it also shows in my WampServer PHP Extensions but it doesn't show in phpinfo(). I coped the php_oauth.dll file into ..\www\bin\php\ext and i also edited php.ini and entered extension=php_oauth.dll but on running the products.php it shows me the

Fatal error: Class 'OAuth' not found in P:\wamp\www\products.php on line 19

而且我还想知道在Magento管理面板中输入新用户后如何获得令牌 key secret .但我不知道如何获取访问令牌&我们在 RESTClient

And i also want to know that how to request for the token i've got key and secret after entering new consumer in Magento Admin Panel. But i don't know how to get Access Token & Access Token Secret that we enter in RESTClient

请帮助,在此先感谢

推荐答案

致命错误的原因是未安装 oauth 库.接下来的步骤来安装库

reason for fatal error is oauth library is not installed. following step to install library

1)从 http://downloads.php.net/pierre/中获取软件包

2)搜索oauth并为您的计算机选择一个

2) search for oauth and choose the one for your machine

3)将该.dll文件放入您的PHP扩展目录中.

3) Put that .dll file in your PHP extensions directory.

4)在php.ini文件中找到扩展区域,并将其添加到其中:

4) Find the extensions area in your php.ini file and add this to it:

[PHP_OAUTH]extension = php_oauth.dll

[PHP_OAUTH] extension=php_oauth.dll

重新启动服务器

在解决致命错误后,如果需要帮助,请检查 http://www.magentocommerce.com/api/rest/introduction.html 用于magento REST API

after solving fatal error if help is required then check http://www.magentocommerce.com/api/rest/introduction.html for magento REST API

使用上面链接中给出的示例代码,其用于获取访问令牌&访问令牌秘密等.您只需要运行php文件

use the sample code given in above link its is used for get Access Token & Access Token Secret etc. you have to just run php file

这篇关于Magento Rest API-oAuth错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆