I want to get the orderList by using soap, the code like the following
<?php
$cs = getSesstion();
$fromDate = date('Y-m-d'. ' 00:00:00', strtotime('-1 days'));
$todayDate = date('Y-m-d'. ' 00:00:00');
$params = array('complex_filter'=>
array('key'=>'created_at','value'=>array('key' =>'gteq','value' => $fromDate)),
array('key'=>'created_at','value'=>array('key' =>'lteq','value' => $todayDate)),
);
$result = $cs['client']->__call('salesOrderList',$params);
//var_dump($result);
function getSesstion() {
//$client = new SoapClient('http://example.com/index.php/api/v2_soap/?wsdl');
$client = new SoapClient('http://example.com/index.php/api/v2_soap/?wsdl');
$username = 'test';
$apikey= 'Abcd1234';
$session = $client->login($username, $apikey);
$cs = array();
$cs['client'] = $client;
$cs['session'] = $session;
return $cs;
}
?>
The error message is
Notice: Array to string conversion in D:\xampp\htdocs\test\soap\call_getorder.php on line 13
Fatal error: Uncaught SoapFault exception: [5] Session expired. Try to relogin. in D:\xampp\htdocs\test\soap\call_getorder.php:13 Stack trace: #0 D:\xampp\htdocs\test\soap\call_getorder.php(13): SoapClient->__call('salesOrderList', Array) #1 {main} thrown in D:\xampp\htdocs\test\soap\call_getorder.php on line 13
Anyone know what is the problem?
Best Answer
It's because of incorrect format in
$params
. You forgot to use an array to embed the whole$param
. So on line 1., modify to the follows:Ref: http://devdocs.magento.com/guides/m1x/api/soap/sales/salesOrder/sales_order.list.html