magento rest api 调用!

1

            $apiUrl = 'http://121.199.39.117/api/rest';
            $consumerKey = '72af70cc284ffda1abe13098a392c3e8';
            $consumerSecret = '78b7efbabeb12bfe0f669e69ab24bf27';
            $authType = OAUTH_AUTH_TYPE_AUTHORIZATION;
            $oauthClient = new OAuth($consumerKey, $consumerSecret, OAUTH_SIG_METHOD_HMACSHA1, $authType);
            $oauthClient->enableDebug();
	    //$oauthClient->setMethod("GET");
            $oauthClient->setToken("0183930ad4c505143fa460430f1240f0", "8fb69a791fad507f6df23ebd9c2d5ed4");
            $resourceUrl = "$apiUrl/orders";
            $oauthClient->fetch($resourceUrl,null,OAUTH_HTTP_METHOD_GET);
            $orderList = json_decode($oauthClient->getLastResponse());
	    var_dump($orderList);

2

api rest 环境配置,参看:

http://blog.csdn.net/terry_water/article/details/19675345

3

获取

oauth_token

oauth_token_secret

通过安装插件

将app\code\local\Vfeelit\RestConnect\controllers/IndexController.php

第七行的参数 $params = array(

和38行的替换:$restClient->setUri('http://121.199.39.117/api/rest/products');

完成后

访问

http://121.199.39.117/restconnect/
3

完成后得到

oauth_token

oauth_token_secret

返回1:

$oauthClient->setToken("0183930ad4c505143fa460430f1240f0", "8fb69a791fad507f6df23ebd9c2d5ed4");
填写这两个值

然后访问即可。




评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值