Posted By

JohnnyGamba on 12/28/10


Tagged

drupal


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

Onfire60
ctronci


How to consume a web service in drupal


 / Published in: PHP
 

  1. $user = 'webservice'; #username (host site).
  2. $password = 'webservice'; #pass (host site).
  3. $xmlrpc_url = 'http://localhost/services.sandbox/services/xmlrpc'; #url to find the web services
  4. $session_id = xmlrpc($xmlrpc_url, 'system.connect');
  5.  
  6. $authenticated_session = xmlrpc($xmlrpc_url, 'user.login', $session_id['sessid'], $user, $password);
  7. $xmlrpc_result = xmlrpc($xmlrpc_url, 'node.get', $authenticated_session['sessid'], 1);
  8.  
  9. if ($xmlrpc_result === FALSE) {
  10. print '<pre>' . print_r(xmlrpc_error(), TRUE) . '<pre>';
  11. }
  12. else {
  13. print '<pre>' . print_r($xmlrpc_result, TRUE) . '<pre>';
  14. }

Report this snippet  

You need to login to post a comment.