【问题标题】:How to setup Magento to get products using REST如何设置 Magento 以使用 REST 获取产品
【发布时间】:2014-06-02 14:46:53
【问题描述】:

我不知道在 magento 中使用 REST 获取产品的网址。 我正在使用教程:

http://inchoo.net/ecommerce/magento/configure-magento-rest-and-oauth-settings/

http://inchoo.net/ecommerce/magento/consuming-magento-rest-zend_oauth_consumer/

问题是我的网址是这种格式: http://magento.loc/magento/index.php/admin/index

但在这些教程中没有 index.php。

在我的代码中是这样的:

    $params = array(
        'siteUrl' => 'http://magento.loc/magento/index.php/oauth',
        'requestTokenUrl' => 'http://magento.loc/magento/index.php/oauth/initiate',
        'accessTokenUrl' => 'http://magento.loc/magento/index.php/oauth/token',
        'authorizeUrl' => 'http://magento.loc/magento/index.php/admin/oAuth_authorize',
        'consumerKey' => '381ywp8r50hxzjw62srozns7pbzzhzrn',
        'consumerSecret' => 'zhjo3nciz9qj3dv6ts6g4bttixg0dqy9',
        'callbackUrl' => 'http://magento.loc/magento/index.php/genr        
                           /test/callback',

    );

在底部: $restClient->setUri('http://magento.loc/magento/index.php/api/rest/products');

使用此配置,我在输入时没有得到任何结果:

      http://magento.loc/magento/index.php/genre/test/index

在浏览器 URL 中, 我收到授权申请问题,按授权后,我得到返回代码 200 的页面, 但没有产品返回(打印 json 响应时显示 404 未找到)

【问题讨论】:

  • 你有一个加号','在你的最后一个键,在 params.. 并删除 callbackurl 中的换行符。

标签: php magento rest magento-1.7


【解决方案1】:

我找到了解决方案:

 'siteUrl' => 'http://magento.loc/magento/oauth',
 'requestTokenUrl' => 'http://magento.loc/magento/oauth/initiate',
 'accessTokenUrl' => 'http://magento.loc/magento/oauth/token',
 'authorizeUrl' => 'http://magento.loc/magento/admin/oAuth_authorize', 
 'consumerKey' => '381ywp8r50hxzjw62srozns7pbzzhzrn',
 'consumerSecret' => 'zhjo3nciz9qj3dv6ts6g4bttixg0dqy9',
 'callbackUrl' => 'http://magento.loc/magento/genre/test/callback'

之后:

 $restClient->setUri('http://magento.loc/magento/api/rest/products');

问题是我没有为 Magento 中当前登录的管理员用户分配角色。 系统 > 权限 > 用户 > 并检查管理员用户的休息角色。 URL里不用写/index.php

【讨论】:

    猜你喜欢
    • 2017-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-18
    • 2019-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多