Posted By

JustGreg on 07/29/09


Tagged

xml-rpc OpenERP


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


OpenERP: XML-RPC Web services


 / Published in: PHP
 

URL: http://doc.openerp.com/developer/6_22_XML-RPC_web_services/

  1. function connect() {
  2. var $user = 'admin';
  3. var $password = 'admin';
  4. var $dbname = 'db_name';
  5. var $server_url = 'http://localhost:8069/xmlrpc/';
  6.  
  7.  
  8. if(isset($_COOKIE["user_id"]) == true) {
  9. if($_COOKIE["user_id"]>0) {
  10. return $_COOKIE["user_id"];
  11. }
  12. }
  13.  
  14. $sock = new xmlrpc_client($server_url.'common');
  15. $msg = new xmlrpcmsg('login');
  16. $msg->addParam(new xmlrpcval($dbname, "string"));
  17. $msg->addParam(new xmlrpcval($user, "string"));
  18. $msg->addParam(new xmlrpcval($password, "string"));
  19. $resp = $sock->send($msg);
  20. $val = $resp->value();
  21. $id = $val->scalarval();
  22. setcookie("user_id",$id,time()+3600);
  23. if($id > 0) {
  24. return $id;
  25. }else{
  26. return -1;
  27. }
  28. }

Report this snippet  

You need to login to post a comment.