Web サービス経由で prestashop への API 接続を作成しようとしています
Custommers、Addresses、Carts を正常に作成できます (顧客の CRUD に関するよく知られた純粋なドキュメントが利用可能で、期待どおりに機能します)
新しい注文を完了できません:
ソースコードの断片があります
require_once('config.php'); // PS_SHOP_PATH etc.
require_once('PSWebServiceLibrary.php');
try
{
$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
$opt = array('resource' => 'orders');
$xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/orders?schema=blank'));
$xml->children()->children()->id_address_delivery = 1;
$xml->children()->children()->id_address_invoice = 1;
$xml->children()->children()->id_cart = 25;
$xml->children()->children()->id_currency = 1;
$xml->children()->children()->current_state = 1;
$xml->children()->children()->id_lang = 1;
$xml->children()->children()->id_customer = 1;
$xml->children()->children()->id_carrier = 0;
$xml->children()->children()->total_paid = '56973';
$xml->children()->children()->total_paid_real = '56973';
$xml->children()->children()->total_paid_tax_excl = '56973';
$xml->children()->children()->total_paid_tax_incl = '56977';
$xml->children()->children()->total_products = 1338;
$xml->children()->children()->total_products_wt = 1337;
$xml->children()->children()->conversion_rate = '1';
$xml->children()->children()->secure_key = md5('-1');;
$xml->children()->children()->valid = 1;
$xml->children()->children()->module = 'Bankwire';
$xml->children()->children()->payment = 'bankwire';
$xml->children()->children()->current_state = 1;
unset($xml->children()->children()->id);
unset($xml->children()->children()->date_add);
unset($xml->children()->children()->date_upd);
unset($xml->children()->children()->associations);
unset($xml->children()->children()->delivery_date);
unset($xml->children()->children()->invoice_date);
unset($xml->children()->children()->total_discounts_tax_incl);
unset($xml->children()->children()->total_discounts_tax_excl);
$xml = $webService->add(array('resource' => 'orders',
'postXml' => $xml->asXML()
));
$resources = $xml->children()->children();
echo "Successfully added order.".$resources->id;
}
catch (PrestaShopWebserviceException $ex)
{
// Here we are dealing with errors
$trace = $ex->getTrace();
if ($trace[0]['args'][0] == 404) echo 'Bad ID';
else if ($trace[0]['args'][0] == 401) echo 'Bad auth key';
else echo 'Other error<br />'.$ex->getMessage();
}
そして部分があります。Fiddler からの webview ログ
XML SENT
xml=<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<order>
<id_address_delivery>1</id_address_delivery>
<id_address_invoice>1</id_address_invoice>
<id_cart>25</id_cart>
<id_currency>1</id_currency>
<id_lang>1</id_lang>
<id_customer>1</id_customer>
<id_carrier>0</id_carrier>
<current_state>1</current_state>
<module>Bankwire</module>
<invoice_number/>
<delivery_number/>
<valid>1</valid>
<id_shop_group/>
<id_shop/>
<secure_key>6bb61e3b7bce0931da574d19d1d82c88</secure_key>
<payment>bankwire</payment>
<recyclable/>
<gift/>
<gift_message/>
<mobile_theme/>
<total_discounts/>
<total_paid>56973</total_paid>
<total_paid_tax_incl>56977</total_paid_tax_incl>
<total_paid_tax_excl>56973</total_paid_tax_excl>
<total_paid_real>56973</total_paid_real>
<total_products>1338</total_products>
<total_products_wt>1337</total_products_wt>
<total_shipping/>
<total_shipping_tax_incl/>
<total_shipping_tax_excl/>
<carrier_tax_rate/>
<total_wrapping/>
<total_wrapping_tax_incl/>
<total_wrapping_tax_excl/>
<shipping_number/>
<conversion_rate>1</conversion_rate>
<reference/>
</order>
</prestashop>
RETURN HTTP BODY 致命的なエラー その他のエラー
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, )), )
「その他のエラー」は次のとおりです。
else echo 'Other error<br />'.$ex->getMessage();
PSWebServiceLibrary が含まれています
/** @var array compatible versions of PrestaShop Webservice */
const psCompatibleVersionsMin = '1.4.0.17';
const psCompatibleVersionsMax = '1.5.4.1';
PrestaShop は 1.5.4.0 です
何かアドバイス?