Reputation: 105
I am working with Magento Rest API for the first time, i went through the tutorials of Rest API on http://www.magentocommerce.com/api/rest
and tried one example to fetch product through API:
$callbackUrl = "http://localhost/wineshop/products.php";
$temporaryCredentialsRequestUrl = "http://localhost/wineshop/oauth/initiate? oauth_callback=" . urlencode($callbackUrl);
$adminAuthorizationUrl = 'http://localhost/wineshop/admin/oauth_authorize';
$accessTokenRequestUrl = 'http://localhost/wineshop/oauth/token';
$apiUrl = 'http://localhost/wineshop/api/rest';
$consumerKey = 'u48p1x9gzrg7r82c94woa5z7g805uw0i';
$consumerSecret = '96ydrk8s89xxath8h5z71vcl5abfq0zg';
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();
I've also installed the latest version of OAUTH and it also shows in my WampServer PHP Extensions but it doesn't show in phpinfo()
. I coped the php_oauth.dll
file into ..\www\bin\php\ext
and i also edited php.ini
and entered extension=php_oauth.dll
but on running the products.php
it shows me the
Fatal error: Class 'OAuth' not found in P:\wamp\www\products.php on line 19
And i also want to know that how to request for the token i've got key
and secret
after entering new consumer in Magento Admin Panel. But i don't know how to get Access Token
& Access Token Secret
that we enter in RESTClient
Please Help, Thanks in advance
Upvotes: 1
Views: 3546
Reputation: 2443
reason for fatal error is oauth library is not installed. following step to install library
1) get the package from http://downloads.php.net/pierre/
2) search for oauth and choose the one for your machine
3) Put that .dll file in your PHP extensions directory.
4) Find the extensions area in your php.ini file and add this to it:
[PHP_OAUTH] extension=php_oauth.dll
restart your server
after solving fatal error if help is required then check http://www.magentocommerce.com/api/rest/introduction.html for magento REST API
use the sample code given in above link its is used for get Access Token & Access Token Secret etc. you have to just run php file
Upvotes: 2