Prestashop webservice - 订单

时间:2015-09-01 14:50:55

标签: php prestashop

我不知道为什么但是我对prestashop和webservice有一个大问题。 一切都很顺利,直到我开始使用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>

有人可以帮我找到问题吗?

感谢

1 个答案:

答案 0 :(得分:0)

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