我在通过WebServices创建新地址时遇到问题Im使用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)
{
}
我收到了"错误响应"错误。有线索吗我做错了什么?
您应该用$opt = array('resource' => 'addresses');
替换行$opt = array('resource' => 'customers');