Return to Snippet

Revision: 38176
at December 28, 2010 05:49 by JohnnyGamba


Initial Code
$user = 'webservice'; #username (host site).
$password = 'webservice'; #pass (host site).
$xmlrpc_url = 'http://localhost/services.sandbox/services/xmlrpc'; #url to find the web services
$session_id = xmlrpc($xmlrpc_url, 'system.connect');

$authenticated_session = xmlrpc($xmlrpc_url, 'user.login', $session_id['sessid'], $user, $password);
$xmlrpc_result = xmlrpc($xmlrpc_url, 'node.get', $authenticated_session['sessid'], 1);

if ($xmlrpc_result === FALSE) {
print '<pre>' . print_r(xmlrpc_error(), TRUE) . '<pre>';
}
else {
  print '<pre>' . print_r($xmlrpc_result, TRUE) . '<pre>';
}

Initial URL

                                

Initial Description

                                

Initial Title
How to consume a web service in drupal

Initial Tags
drupal

Initial Language
PHP