2016-11-30 4 views
0

私は、以下のリンクから作業MagentoのREST APIの例(OAuth認証を持つ管理者ユーザーとして、単純な製品を作成します。)を取得しようとしている:私はしかしMagentoのREST APIの例のエラー

http://devdocs.magento.com/guides/m1x/api/rest/introduction.html

次のエラーを受け取る:

enter image description here

はるかにOAuthをインストールする方法を動作するようにした後、これを取得するために私にかなりの時間がかかったし、この部分は私と全く苦痛になってきているキャンこれらのエラーの解決策を見つけることはできません。

誰にも全くアイデアはありますか?私のコードは、必要に応じて以下のとおりです。

<?php 
$callbackUrl = "http://localhost/API.php"; 
$temporaryCredentialsRequestUrl = "https://ts564737-container.zoeysite.com/oauth/initiate?oauth_callback=" . urlencode($callbackUrl); 
$adminAuthorizationUrl = 'https://ts564737-container.zoeysite.com/admin/oauth_authorize'; 
$accessTokenRequestUrl = 'https://ts564737-container.zoeysite.com/oauth/token'; 
$apiUrl = 'https://ts564737-container.zoeysite.com/api/rest'; 
$consumerKey = '526ced0202719d14951e1849016d6b3d'; 
$consumerSecret = 'a06606b73962a0efbafea32af3d89380'; 

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"; 
     $productData = json_encode(array(
      'type_id'   => 'simple', 
      'attribute_set_id' => 4, 
      'sku'    => 'simple' . uniqid(), 
      'weight'   => 1, 
      'status'   => 1, 
      'visibility'  => 4, 
      'name'    => 'Simple Product', 
      'description'  => 'Simple Description', 
      'short_description' => 'Simple Short Description', 
      'price'    => 99.95, 
      'tax_class_id'  => 0, 
     )); 
     $headers = array('Content-Type' => 'application/json'); 
     $oauthClient->fetch($resourceUrl, $productData, OAUTH_HTTP_METHOD_POST, $headers); 
     print_r($oauthClient->getLastResponseInfo()); 
    } 
} catch (OAuthException $e) { 
    print_r($e); 
} 

ありがとうございました。

答えて

0

PHPスクリプトに$ oauth-> disableSSLChecks()を追加することで修正された証明書の問題。

問題をerror_reporting(E_ALL | E_STRICT)を追加して修正しました。 PHPスクリプトに追加します。

関連する問題