I have been trying off and on for about a week to get a connection made to Magento’s API via a PHP script.
Magento gives the following code snippet on their site, but I could not get it to work – souring the message boards didn’t really help either. I am not sure if something was off with my installation instance or what.
-
$client = new Zend_XmlRpc_Client(‘http://youmagentohost/api/xmlrpc/’);
-
// If somestuff requires api authentification,
-
// we should get session token
-
$session = $client->call(‘login’, array(‘apiUser’, ‘apiKey’));
-
$client->call(‘call’, array($session, ‘somestuff.method’, array(‘arg1′, ‘arg2′, ‘arg3′)));
-
$client->call(‘call’, array($session, ‘somestuff.method’, ‘arg1′));
-
$client->call(‘call’, array($session, ‘somestuff.method’));
-
$client->call(‘multiCall’, array($session,
-
array(
-
array(‘somestuff.method’, ‘arg1′),
-
array(‘somestuff.method’, array(‘arg1′, ‘arg2′)),
-
array(‘somestuff.method’)
-
)
-
));
-
// If you don’t need the session anymore
-
$client->call(‘endSession’, array($session));
After a bunch of trial and error – scouring the web etc – i was finally able to make a connection with the following script
<?php
ini_set("display_errors", 1);
error_reporting(E_ALL);
define("XMLRPC_DEBUG", 1);
require_once('../app/Mage.php');
$client = new Zend_XmlRpc_Client('http://www.domain.com/api/xmlrpc');
// If somestuff requires api authentification, we should get session token
$session = $client->call('login', array('user', 'key'));
echo "<pre>";
print_r($session);
echo "</pre>";
// If you don't need the session anymore
$client->call('endSession', array($session));
?>
one strange thing to note is the path to the API – with a trailing slash, i could not get this to work…’
I hope that this helps someone else out.

Subscribe
Screenfluent
Best Web Gallery
CSS Beauty
The Best Designs
Styleboost