OpenERP: XML-RPC Web services


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.