Magento ver.1.7.0.2
我是Magento,REST和oauth的新手.我希望能够使用Magento REST API来修改具有内部客户管理系统的在线商店.我已经能够轻松地设置Magento,但我正在努力使用REST,尤其是oauth.
我目前在OSX 10.7.5上的MAMP 2.1.1上运行Magento.我能够使用以下方向安装OAUTH:在MAMP环境中安装PHP OAuth
在Magento教程之后,我使用Firefox RESTClient来测试OAuth.我在Magento中设置了角色和消费者,并将密钥放在RESTClient的相应字段中.
当我发布到
http://localhost:8888/store/oauth/initiate?oauth_callback=http://localhost:8888/store/oauth_admin.php
Run Code Online (Sandbox Code Playgroud)
我得到了回应
oauth_problem=signature_invalid&debug_sbs=QiIiTo3WGTZLTOhyIest9B5+l5s=
Run Code Online (Sandbox Code Playgroud)
在Magento上使用测试PHP脚本(http://www.magentocommerce.com/api/rest/introduction.html)
<?php
/**
* Example of products list retrieve using admin account via Magento REST
API. oAuth authorization is used
*/
$callbackUrl = "http://localhost:8888/store/oauth_admin.php";
$temporaryCredentialsRequestUrl =
"http://localhost:8888/store/oauth/initiate?oauth_callback=" .
urlencode($callbackUrl);
$adminAuthorizationUrl = 'http://localhost:8888/store/admin/oAuth_authorize';
$accessTokenRequestUrl = 'http://localhost:8888/store/oauth/token';
$apiUrl = 'http://localhost:8888/store/api/rest';
$consumerKey = 'obscured';
$consumerSecret = 'obscured';
session_start();
if (!isset($_GET['oauth_token']) && isset($_SESSION['state']) &&
$_SESSION['state'] == 1) {
$_SESSION['state'] = 0;
}
try {
$authType = …Run Code Online (Sandbox Code Playgroud)