2017-05-02 1 views
0

私はprestashopチュートリアルに従いました。302にサーバーからエラーが見つかりました。 鍵は神、私はすべての許可のトラフを持っています。ローカルホストからPrestashop webservice 302エラーが発生しました

アイデアはありますか?

// Here we define constants /!\ You need to replace this parameters 
define('DEBUG', true);           // Debug mode 
define('PS_SHOP_PATH', 'http://127.0.0.1/mystore/prestashop/');  // Root path of your PrestaShop store 
define('PS_WS_AUTH_KEY', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'); // Auth key (Get it in your Back Office) 
require_once('./PSWebServiceLibrary.php'); 

// Here we make the WebService Call 
try 
{ 
    $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); 

    // Here we set the option array for the Webservice : we want customers resources 
    $opt['resource'] = 'customers'; 

    // Call 
    $xml = $webService->get($opt); 

    // Here we get the elements from children of customers markup "customer" 
    $resources = $xml->customers->children(); 
} 
catch (PrestaShopWebserviceException $e) 
{ 
    // Here we are dealing with errors 
    $trace = $e->getTrace(); 
    if ($trace[0]['args'][0] == 404) echo 'Bad ID'; 
    else if ($trace[0]['args'][0] == 401) echo 'Bad auth key'; 
    else echo 'Other error'; 
} 

答えて

1

HTTPステータスコード302はリダイレクトされているため、証明書に問題があるとは考えられません。私の最初の推測では、URLに/を追加する必要があるということです。一部のHTTPサーバフレームワークは、代わりに、リソースが/で終わっていない時にリダイレクトし、そうします:このリソースが認証を必要とし、サーバは、ログインページにリダイレクトされていることを

GET /endPoint 

Try 

GET /endPoint/ 

他の可能性があります。何が起こっているのかを知りたい場合は、302のレスポンスヘッダを見てください。サーバがどこに行きたいかを示すLocationヘッダがあります。

関連する問題