【问题标题】:Prestashop webservice 302 error from localhost来自本地主机的 Prestashop webservice 302 错误
【发布时间】:2017-09-29 10:02:55
【问题描述】:

我遵循 prestashop 教程,我从服务器收到 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';
}

【问题讨论】:

    标签: php apache web-services prestashop-1.6 prestashop-1.7


    【解决方案1】:

    HTTP 状态码 302 是重定向,因此不太可能是由于证书问题。我最初的猜测是您需要从您的 URL 中添加 / (或删除它)。当资源不以 / 结尾时,一些 http 服务器框架会重定向,所以,而不是:

    GET /endPoint
    
    Try
    
    GET /endPoint/
    

    另一种可能性是此资源需要身份验证,并且服务器将您重定向到登录页面。如果您想知道发生了什么(而不是猜测),请查看 302 的响应标头。会有一个 Location 标头告诉您服务器希望您去哪里。

    【讨论】:

      猜你喜欢
      • 2018-04-21
      • 1970-01-01
      • 2021-12-24
      • 2021-03-29
      • 2013-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多