Using magento rest API i can see the data of product, category etc using
https://magentohost/api/rest/products, Here is can see list of products but when i access
https://magentohost/api/rest/orders it says forbidden, I have assined all access to admin and guest but still it does not show it.
http://devdocs.magento.com/guides/m1x/api/rest/Resources/Orders/sales_orders.html
Here is my PHP code which works for product data but when i change products to orders it shows blank array
<?php
$callbackUrl = "http://localhost/magento_navo/rest.php";
$temporaryCredentialsRequestUrl = "http://localhost/magento_navo/oauth/initiate?oauth_callback=" . urlencode($callbackUrl);
$adminAuthorizationUrl = 'http://localhost/magento_navo/admin/oauth_authorize';
$accessTokenRequestUrl = 'http://localhost/magento_navo/oauth/token';
$apiUrl = 'http://localhost/magento_navo/api/rest';
$consumerKey = '5d93150171fa64e87ae316646f07b0ae';
$consumerSecret = '06b312b7b8ea4e7c6319f00bf49f1e35';
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();
if (!isset($_GET['oauth_token']) && !$_SESSION['state']) {
$requestToken = $oauthClient->getRequestToken($temporaryCredentialsRequestUrl);
$_SESSION['secret'] = $requestToken['oauth_token_secret'];
$_SESSION['state'] = 1;
header('Location: ' . $adminAuthorizationUrl . '?oauth_token=' . $requestToken['oauth_token']);
exit;
} else if ($_SESSION['state'] == 1) {
$oauthClient->setToken($_GET['oauth_token'], $_SESSION['secret']);
$accessToken = $oauthClient->getAccessToken($accessTokenRequestUrl);
$_SESSION['state'] = 2;
$_SESSION['token'] = $accessToken['oauth_token'];
$_SESSION['secret'] = $accessToken['oauth_token_secret'];
header('Location: ' . $callbackUrl);
exit;
} else {
$oauthClient->setToken($_SESSION['token'], $_SESSION['secret']);
//$resourceUrl = "$apiUrl/products";
$resourceUrl = "$apiUrl/orders";
$oauthClient->fetch($resourceUrl, array(), 'GET', array('Content-Type' => 'application/json', 'Accept' => '*/*'));
$productsList = json_decode($oauthClient->getLastResponse());
echo "<pre>";
print_r($productsList);
}
} catch (OAuthException $e) {
print_r($e);
Output:
stdClass Object
(
[41] => Array
(
)
[42] => Array
(
)
[43] => Array
(
)
[44] => Array
(
)
[46] => Array
(
)
[47] => Array
(
)
[48] => Array
(
)
[49] => Array
(
)
[50] => Array
(
)
[51] => Array
(
)