Php PrestaShop webService返回意外的HTTP状态503

Php PrestaShop webService返回意外的HTTP状态503,php,prestashop,Php,Prestashop,我正在将基于PHP的仓库管理系统与PrestaShop1.6集成,并使用PrestashopWeb服务进行集成 我必须使在仓库管理系统中创建的新产品出现在PrestaShop 1.6在线商店中。仓库管理系统要求PrestaShop WebService在PrestaShop在线商店上创建新产品 我已经编写了如下所示的函数。它在本地主机上运行良好,但在测试服务器上,它在尝试更新库存可用性后收到HTTP状态503。所有WebService实体上都启用了所有WebService方法GET、PUT、DE

我正在将基于PHP的仓库管理系统与PrestaShop1.6集成,并使用PrestashopWeb服务进行集成

我必须使在仓库管理系统中创建的新产品出现在PrestaShop 1.6在线商店中。仓库管理系统要求PrestaShop WebService在PrestaShop在线商店上创建新产品

我已经编写了如下所示的函数。它在本地主机上运行良好,但在测试服务器上,它在尝试更新库存可用性后收到HTTP状态503。所有WebService实体上都启用了所有WebService方法GET、PUT、DELETE等。我不知道如何调试这个问题,你能帮我吗

顺便说一下,我使用了以下代码作为示例:


在大多数主机中,PUT请求默认关闭。你有没有和你的托管经理核实过?? 无论如何,你必须在解决这个问题后,才能知道错误的确切原因


祝你好运。

几周后,我被要求回来解决PrestaShop网站服务问题。亲爱的PrestaAlba,非常感谢,你的建议非常有用。我需要取消阻止PUT和DELETE HTTP方法。当然,现在我知道这些PUT和DELETE方法被阻止是因为安全原因,这些方法很容易被利用,所以我只为我们的仓库管理系统所在服务器的一个IP地址解除了这些方法的阻止。
private function saveProduct($update, $webService, $root_path, $n_id, $n_id_category_default, $n_id_category, $n_price, $n_active, $n_avail4order, $n_show_price, $n_l_id, $n_name, $n_desc, $n_desc_short, $n_link_rewrite, $n_meta_title, $n_meta_description, $n_meta_keywords, $n_available_now, $n_available_later, $idtaglist, $cod, $quantity) {

        $webService = new PrestaShopWebservice($this->ps_shop_path, $this->ps_ws_auth_key, $this->ps_ws_debug);

        $xml = $webService->get(array('url' => $root_path . '/api/products?schema=blank'));
        $resources = $xml->children()->children();

        /*
        many values of attributes of XML object $resources are assigned here, instead of this comment
        */

        $id = "";
        try {
            $opt = array('resource' => 'products');
            if(!$update){
                $opt['postXml'] = $xml -> asXML();
                $xml = $webService -> add($opt);
                $id = $xml->product->id;
            }
            else{
                $opt['putXml'] = $xml -> asXML();
                $opt['id'] = $n_id;
                $xml = $webService -> edit($opt);
                $id = $n_id;
            }
        }
        catch (PrestaShopWebserviceException $ex) {
            echo '<b>Error : '.$ex->getMessage().'</b>';
        }

        $resources = $xml->children()->children();
        $stock_available_id = $resources->associations->stock_availables->stock_available[0]->id;
        /*
        Here we get the sotck available with were product id
        */
        try
        {
            $opt = array('resource' => 'stock_availables');
            $opt['id'] = $stock_available_id;
            $xml = $webService->get($opt);
        }
        catch (PrestaShopWebserviceException $e)
        {
            $trace = $e->getTrace();
            if ($trace[0]['args'][0] == 404) die('1:Bad ID');
            else if ($trace[0]['args'][0] == 401) die('1:Bad auth key');
            else die('1:Other error '.$e->getMessage());
        }
        $resources = $xml->children()->children();
        $resources->quantity = $quantity;
        /*
        There we call to save our stock quantity.
        */
        try
        {
            $opt = array('resource' => 'stock_availables');
            $opt['putXml'] = $xml->asXML();
            $opt['id'] = $stock_available_id;
            $xml = $webService->edit($opt);
            echo "Successfully updated.";
        }
        catch (PrestaShopWebserviceException $e)
        {
            $trace = $e->getTrace();
            if ($trace[0]['args'][0] == 404) die('2:Bad ID');
            else if ($trace[0]['args'][0] == 401) die('2:Bad auth key');
            else echo('Other error: '.$e->getMessage()); // function echoes this PrestaShopWebServiceException: "Other error: This call to PrestaShop Web Services returned an unexpected HTTP status of:503"
        }

    }