PrestaShop WebServices添加地址

时间:2015-04-04 10:33:01

标签: php web-services prestashop prestashop-1.6

我遇到通过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错误。任何线索我做错了什么?

1 个答案:

答案 0 :(得分:0)

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