Fehler während der Verwendung der REST-api in magento

Ich habe magento lokal auf meinem system mit XAMPP

Habe ich eine Datei in das root-Verzeichnis mit dem Namen dm.php mit dem Inhalt

<?php
/**
* Example of products list retrieve using Customer account via Magento REST API. OAuth authorization is used
*/
$callbackUrl = "http://localhost/dm.php";
$temporaryCredentialsRequestUrl = "http://localhost/mage2/oauth/initiate?oauth_callback=" . urlencode($callbackUrl);
$adminAuthorizationUrl = 'http://localhost/mage2/oauth/authorize';
$accessTokenRequestUrl = 'http://localhost/mage2/oauth/token';
$apiUrl = 'http://localhost/mage2/api/rest';
$consumerKey = 'enhksf7u33p3snubewb6zcq0z9c63bvv';
$consumerSecret = 'p7e835cdcxofokeep749jgzz4l1e306p';

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);
}

Aber das gibt mir die folgende Fehlermeldung

Fatal error: Class 'OAuth' not found in D:\Webserver\xampp\htdocs\dm.php on line 19

Kann jemand etwas Licht in diese Schuppen
Dank

Seit oauth ist nicht möglich, die Installation in xampp windows ich habe die Inhalte meiner dm.php Datei auf dieses.

<?php
$ch = curl_init('http://localhost/mage2/api/rest/customers');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$customers = curl_exec($ch);
echo $customers;
?>

Nun erhalte ich eine Fehlermeldung wie diese

{"messages":{"error":[{"code":403,"message":"Access denied"}]}}

Was mache ich falsch?

  • Ist Ouath aktiviert in der Xampp-server? Ihr passiert durch, dass
  • ich überprüfte nun. seine nicht aktiviert.Aber ich glaube, es gibt keine Möglichkeit, die wir installieren können, oauth xampp
  • magentocommerce.com/api/rest/authentication/... dieser link könnte dir helfen
  • Consumer key, Consumer secret, Access token, Access token secret, die erforderlich sind
InformationsquelleAutor zamil | 2012-12-13
Schreibe einen Kommentar