【问题标题】:PrestaShop WebServices Add addressPrestaShop WebServices 添加地址
【发布时间】:2015-10-15 03:05:36
【问题描述】:

我在通过 WebServices 创建新地址时遇到问题 我使用 PrestaShop 1.6.0.14 和 PSWebServiceLibrary 这是我的代码:

                    try
                    {
                        $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
                        $xml = $webService->get( array( 'url' => 'http://raj-dla-ogrodu.pl/api/addresses?schema=blank' ) );
                        $resources = $xml->children()->children();
                        $infos = array(
                            'id_customer' => '50',
                            'id_country' => '14',
                            'id_state' => '0',
                            'alias' => 'Allegro',
                            'id_manufacturer' => '0',
                            'id_supplier' => '0',
                            'id_warehouse' => '0',
                            'deleted' => '0',
                            'lastname' => 'test',
                            'firstname' => 'test',
                            'address1' => 'Klient',
                            'address2' => '111',
                            'postcode' => $transakcje->RecipientZip,
                            'city' => 'test',
                            'phone_mobile' => $transakcje->RecipientPhone,
                            'phone' => $transakcje->RecipientPhone,

                            );
                        foreach ($resources as $nodeKey => $node)
                        {
                            $resources->$nodeKey = $infos[$nodeKey];
                        }
                        $opt = array('resource' => 'customers');
                         $opt['postXml'] = $xml->asXML();
                         $xml = $webService->add($opt);
                    }
                    catch (PrestaShopWebserviceException $ex)
                    {
                    }

我收到了 Bad Response 错误。任何线索我做错了什么?

【问题讨论】:

  • 在浏览器中尝试url,如果它是正确的,只需很少的参数。

标签: php web-services prestashop prestashop-1.6


【解决方案1】:

您应该将$opt = array('resource' => 'customers'); 行替换为$opt = array('resource' => 'addresses');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-07
    • 1970-01-01
    • 2019-02-11
    • 1970-01-01
    • 2017-01-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多