我按照此页面http://www.magentocommerce.com/api/rest/Resources/inventory.html#RESTAPI-Resource-StockItems-HTTPMethod-PUT-stockitems--id的说明操作,我有以下代码:
$oauthClient->setToken($_SESSION['token'], $_SESSION['secret']);
$resourceUrl = $apiUrl.'/stockitems/429';
$productData = json_encode(array(
'qty' => 982,
'is_in_stock' => 1
));
$headers = array('Content-Type' => 'application/json');
$oauthClient->fetch($resourceUrl, $productData, OAUTH_HTTP_METHOD_POST, $headers);
print_r($oauthClient->getLastResponseInfo());
但我得到了回报
[message:protected] => Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect)
我尝试使用这样的 XML:
$oauthClient->setToken($_SESSION['token'], $_SESSION['secret']);
$resourceUrl = $apiUrl.'/stockitems/429';
$productData = '<?xml version="1.0"?>
<magento_api>
<qty>99</qty>
</magento_api>';
$headers = array('Content-Type' => 'text/xml');
$oauthClient->fetch($resourceUrl, $productData, OAUTH_HTTP_METHOD_POST, $headers);
print_r($oauthClient->getLastResponseInfo());
我得到了错误:
[message:protected] => Invalid auth/bad request (got a 405, expected HTTP/1.1 20X or a redirect)
我不知道我做错了什么?
感谢你的回复。