Prestashop Webservice XML 响应解析错误



我正在尝试通过API将我的订单从我的供应商导入到我的PS 1.6.0.14。好吧,在本地主机中一切正常,但现在在服务器上我遇到了一个大问题。

尝试检查客户是否存在时,我收到此错误。

HTTP XML response is not parsable: array ( 0 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 4, 'column' => 1, 'message' => 'Start tag expected, '<' not found ', 'file' => '', 'line' => 1, )), )

检查客户是否存在的功能是:

function custExist($email_ws, $webService){
    $opt = [
        'resource'      => 'customers',
        'display'       => '[email]',
        'filter[email]' => '['.$email_ws.']',
        'limit'         => '1',
    ];
    //After this call, I've got the error.
    $xml = $webService->get($opt);
    if($email_ws == $xml->customers->customer->email)
        return FALSE;
    else
        return TRUE;
}

最后,Web 服务 get 函数:

public function get($options)
{
    if (isset($options['url']))
        $url = $options['url'];
    elseif (isset($options['resource']))
    {
        $url = $this->url.'/api/'.$options['resource'];
        $url_params = array();
        if (isset($options['id']))
            $url .= '/'.$options['id'];
        $params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop');
        foreach ($params as $p)
            foreach ($options as $k => $o)
                if (strpos($k, $p) !== false)
                    $url_params[$k] = $options[$k];
        if (count($url_params) > 0)
            $url .= '?'.http_build_query($url_params);
    }
    else
        throw new PrestaShopWebserviceException('Bad parameters given');
    $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET'));
    self::checkStatusCode($request['status_code']);// check the response validity
    return self::parseXML($request['response']);
}

有什么技巧可以解决这个问题吗?提前谢谢。

编辑:我已经从后端删除了友好的URL,现在错误更大了...如果我在响应返回中为 Web 服务调用启用调试模式,我有一些 HTML 代码,没有 JSON 响应。有点奇怪...

RETURN HTTP BODY
<!DOCTYPE HTML>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="es-es"><![endif]-->
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8 ie7" lang="es-es"><![endif]-->
<!--[if IE 8]><html class="no-js lt-ie9 ie8" lang="es-es"><![endif]-->
<!--[if gt IE 8]> <html class="no-js ie9" lang="es-es"><![endif]-->
<html lang="es-es">
    <head>
        <meta charset="utf-8" />
        <title>PAGE TITLE</title>
        <meta name="description" content="Tienda creada con PrestaShop" />
        <meta name="keywords" content="tienda, prestashop" />
        <meta name="generator" content="PrestaShop" />
        <meta name="robots" content="index,follow" />
        <meta name="viewport" content="width=device-width, minimum-scale=0.25, maximum-scale=1.6, initial-scale=1.0" />
        <meta name="apple-mobile-web-app-capable" content="yes" />
        <link rel="icon" type="image/vnd.microsoft.icon" href="/img/favicon.ico?1482254072" />
.......

编辑2:好的,问题解决了。用于调用 API Web 服务的 URL,例如 www.myprestashop.com/api/customers 将我重定向到我的商店前端。

知道吗?:(

也许与 CHMOD 权限有关。如果您使用的是 AWS 服务,我 100% 确定就是这样。

那么,没有来自 Web 服务的数据?拨打其他类型的电话。

最新更新