Hey guys,
Apologies in advance, i am still fairly new to php…
I am making a call to a web service which retrieves a list of all products whose stock quantity has changed since the information was last requested. I want to then Update the stock quantities for the products in a MYSQL database.
So far the code i have is as follows
[php]
<?php $wsdl = 'https://www.connectwebservice.com/gripcycl_test/services/IR?wsdl'; // TODO: change this to your wsdl ini_set("soap.wsdl_cache_enabled", "0"); // TODO: disable WSDL cache if required ini_set("default_socket_timeout", 10); // TODO: set appropriate read timeout $client = new SoapClient($wsdl, array("connection_timeout"=>5)); // conneting to SOAP - TODO: set appropriate connect timeout $days = 7; // Get all products that have changed in the past 7 days $date = date('d/m/Y 00:00', (time() - ($days * 24 * 60 * 60))); $productCodes = $client->getProductCodesChangedSinceDateStrForType(array("lastRequestDateStr" => $date, "leafOnly" => true))->getProductCodesChangedSinceDateStrForTypeReturn; // note: using getProductCodesChangedSinceLastRequestForType(boolean leafOnly) instead will get all products changed since the last time this request was made if ($productCodes != '') { $productCodes = split(',', $productCodes); } foreach ($productCodes as $productCode) { $currentStockQuantity = $client->getProductQuantity($productCode); } ?> <?php $con = mysql_connect("localhost","gripcycl_osc1","WeUM8S4Owf0C"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("gripcycl_osc1", $con); foreach ($productCodes as $productCode) { mysql_query("UPDATE products SET products_quantity='$currentStockQuantity' WHERE products_model='$productCode'"); } mysql_close($con); ?>[/php]
It would seem that whenever I relate to the $currentStockQuantity variable I get the error
“Catchable fatal error: Object of class stdClass could not be converted to string in…”
Using Var_dump and Print_r on $currentStockQuantity, returns
"object(stdClass)#2 (1) { [“getProductQuantityReturn”]=> int(0) }
stdClass Object ( [getProductQuantityReturn] => 0 )
instead of returning values. Can anyone see where i am going wrong?
Thanks, Carl