ODOO Web服务将php表单发送到odoo

时间:2018-09-10 11:44:34

标签: odoo-10

我需要使用php将请求发送到我的URL到odoo 10到特定模型,但出现错误:在整数上调用成员函数scalarval() 请任何人知道的可以快速帮助我

<?php
include("xmlrpc.inc");

$user = "Ammar";
$password = "1235";
$db = "Test";
$serverUri = "http://localhost:8080/";

$client = new xmlrpc_client($serverUri . 'common');
$msg = new xmlrpcmsg('login');
$msg->addParam(new xmlrpcval('9_xmlrpc', "string"));
$msg->addParam(new xmlrpcval('admin', "string"));
$msg->addParam(new xmlrpcval('admin', "string"));
$res = $client->send($msg);
$val = $res->value();
$id = $val->scalarval();

$create_feedback_form = array(
        'name' =>new xmlrpcval($_POST['name'],'string'),
        'description' =>new xmlrpcval($_POST['description'],'string'),
        'phone' =>new xmlrpcval($_POST['phone'],'string'),
);

$client = new xmlrpc_client($serverUri . 'object');
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval('9_xmlrpc', "string"));
$msg->addParam(new xmlrpcval('1', "int"));
$msg->addParam(new xmlrpcval('admin', "string"));
$msg->addParam(new xmlrpcval("feedback.form", "string"));
$msg->addParam(new xmlrpcval("create", "string"));
$msg->addParam(new xmlrpcval($create_feedback_form, "struct"));
$res = $client->send($msg); 
if($res){
    echo 'Successfully Submited'; exit; 
}
?>

1 个答案:

答案 0 :(得分:0)

您应该尝试使用更友好且受支持的php xmlrpc库(例如ripcord),您会在以下位置找到更多帮助和示例,如:

https://www.odoo.com/documentation/11.0/webservices/odoo.html