[Magento] Example WebService connection

Data dodania wpisu: 17-09-2010

How to connect to Magento remotely? By WebServices for example. Short script with necessary lines of code:

We can load products for example:

$host = "www.shop.com"; //our online shop url
$client = new SoapClient("http://".$host."/api/soap/?wsdl"); //soap handle
$apiuser= "login-webservice"; //webservice user login
$apikey = "password-webservice"; //webservice user pass
$action = "catalog_product.list"; //an action to call later (loading products in here)
try {  
    $sess_id= $client->login($apiuser, $apikey); //we do login 
    $result= $client->call($sess_id, $action, array()); //call an action
    print_r($result); //printing out the results:)
catch (Exception $e) { //while an error has occured
    echo "==> Error: ".$e->getMessage(); //we print this
Remember: create webservice user first and attach correct permissions to him:)


This entry has no comments yet

Comments closed...

DesignEnd on Facebook