I have a core php website where client create a different type of widgets to get reporting in the form of charts. I want to develop widget for that purpose to show Magento orders reporting , sales reporting etc on php site using Magento store API. Anyone know about magento Api to get product information please tell me.
I am using this code
<?php
$callbackUrl = "https://air.co.uk/oauth_customer.php";
$temporaryCredentialsRequestUrl = "https://air.co.uk/oauth/initiate?oauth_callback=" . urlencode($callbackUrl);
$adminAuthorizationUrl = 'https://air.co.uk/oauth/authorize';
$accessTokenRequestUrl = 'https://air.co.uk/oauth/token';
$apiUrl = 'https://air.co.uk/api/rest';
$consumerKey = 'xb4up56a4f95ewl4l5s6xp097wi6g4uwv';
$consumerSecret = 'ust6oh4t63fw5wcjo8gkqdpgc4tw0iscx';
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";
$oauthClient->fetch($resourceUrl);
$productsList = json_decode($oauthClient->getLastResponse());
print_r($productsList);
}
} catch (OAuthException $e) {
print_r($e);
}
?>
But I am facing this error
Fatal error: Class 'OAuth' not found in /home/air/public_html/mapiuse/index.php on line 18
Plese help where from add OAuth class. And what will be the best solution to get my job. thanks