【问题标题】:Prestashop webservice - OrdersPrestashop 网络服务 - 订单
【发布时间】:2015-11-26 20:57:39
【问题描述】:

我不知道为什么,但我对 prestashop 和 web 服务有一个大问题。 在我开始使用 orders 之前,一切都运行良好。

productscategories 等其他资源完美运行。

但订单总是返回500 Internal Server Error

这是我的orders_get.php

<?php
require_once('PSWebServiceLibrary.php');
define('STORE_PATH','http://localhost/prestashop');
define('KEY','KN5NBZWT3QYLGZX86DV14ZX317BHVPTL');
define('DEBUG',true);

$webService = new PrestaShopWebservice(STORE_PATH, KEY, DEBUG);

$opt = array(
    'resource' => 'orders',
    'display'  => 'full',
    'sort'     => '[id_ASC]'
);

$xml = $webService->get($opt);
$resources = $xml->children()->children();
$cont = 1;
$array_datos=[];

foreach ($resources as $key => $resource){
    $array_datos[$cont] = $resource -> children();

    $cont++;
}

$txt = "";
$contador = count($array_datos);
for ($i=1; $i <= $contador ; $i++) { 

    $registro['resource'] = 'orders';

    $registro['id'] = $array_datos[$i];
    $estructura = $webService->get($registro);
    $order = $estructura->order->children();

    foreach ($order as $key => $resource){
        $txt .= $resource . '$nx$';
    }



    $txt .= '|';
}

$txt = preg_replace("/\r\n+|\r+|\n+|\t+/i", "", $txt);

    $myfile = fopen("orders.txt", "w") or die("Unable to open file!");      
        fwrite($myfile, $txt);
        fclose($myfile);

?>

这是我的脚本的响应。

HTTP REQUEST HEADER
GET /prestashop/api/orders?display=full&sort=%5Bid_ASC%5D HTTP/1.1
Authorization: Basic S041TkJaV1QzUVlMR1pYODZEVjE0WlgzMTdCSFZQVEw6
Host: localhost
Accept: */*

HTTP RESPONSE HEADER
HTTP/1.1 500 Internal Server Error
Date: Tue, 01 Sep 2015 14:40:48 GMT
Server: Apache/2.4.12 (Win32) OpenSSL/1.0.1l PHP/5.6.8
X-Powered-By: PrestaShop Webservice
Access-Time: 1441118448
PSWS-Version: 1.6.0.14
Execution-Time: 0.009
Content-Sha1: c1e4bd1c1ab618bfd40e07e81ba5d666a0380e1e
Set-Cookie: PrestaShop-42d71ccdbde431a9af735bab5d1ba278=Zk5GPKjZT%2F9ePuqzF7wTo%2Bx26JD8MiaijborY9jVLUmTDo97lOst2ttGYjBNvELPIwhPg6%2BTYTPhnMNqaDGw5lW%2BG9FCn5RGzXW1x5ZSjGs%3D000078; expires=Mon, 21-Sep-2015 14:40:48 GMT; Max-Age=1728000; path=/prestashop/; httponly
Content-Length: 693
Connection: close
Content-Type: text/xml;charset=utf-8

RETURN HTTP BODY
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<errors>
<error>
<message><![CDATA[Internal error. To see this error please display the PHP errors.]]></message>
</error>
<error>
<message><![CDATA[Internal error. To see this error please display the PHP errors.]]></message>
</error>
<error>
<message><![CDATA[Internal error. To see this error please display the PHP errors.]]></message>
</error>
<error>
<message><![CDATA[Internal error. To see this error please display the PHP errors.]]></message>
</error>
<error>
<message><![CDATA[Internal error. To see this error please display the PHP errors.]]></message>
</error>
</errors>
</prestashop>

谁能帮我找出我的问题?

谢谢

【问题讨论】:

  • 请启用调试模式,我们可以看到详细的错误 - 转到 /config/defines.php 并将 PS_MODE_DEV 更改为 true
  • 嗨,首先,谢谢。怎么可能只有当我激活PS_MODE_DEV 为真时,调用才不会返回任何错误。实际上是从订单中返回所有数据。 When the option is on false the error comes back again.对此有何解释? :)

标签: php prestashop


【解决方案1】:

如果仅在您尝试获取订单时失败,则可能您的 KEY 没有查看订单的权限。如果有足够的权限来获取它,请检查您的 BO。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-01
    • 2015-02-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多