openerp和php xmlrpc在共享主机上不起作用,但在本地主机上起作用
我有ipage主机服务器,当我尝试在我的服务器上上传我的php代码时,它没有与openerp建立连接,但当我在localhost上尝试时,它工作正常 并产生潜在客户。我希望它在我的网站上的实时共享服务器(Ipage)工作。 这是我的Openerp服务器配置文件 我的openerp服务器托管在本地服务器上,我通过静态IP地址连接它openerp和php xmlrpc在共享主机上不起作用,但在本地主机上起作用,php,openerp,xml-rpc,Php,Openerp,Xml Rpc,我有ipage主机服务器,当我尝试在我的服务器上上传我的php代码时,它没有与openerp建立连接,但当我在localhost上尝试时,它工作正常 并产生潜在客户。我希望它在我的网站上的实时共享服务器(Ipage)工作。 这是我的Openerp服务器配置文件 我的openerp服务器托管在本地服务器上,我通过静态IP地址连接它 [options] ; This is the password that allows database operations: ; admin_passwd
[options]
; This is the password that allows database operations:
; admin_passwd = XXXXXX
db_host = False
db_port = False
db_user = openerp
xmlrpc = True
xmlrpc_port = 8069
xml_netrpc = 8071
db_password = False
logfile = /var/log/openerp/openerp-server.log
这是我的crmlead.php文件
<?php
include("xmlrpc.inc");
class Contact
{
private $subject = '', $to = '';
function __construct($to, $sub)
{
$this->to = $to;
$this->subject = $sub;
}
function xmlCallTo($usr, $password, $database, $server, $post)
{
$user = $usr;
$pass = $password;
$db = $database;
$server_url = $server; //'http://localhost:8069/xmlrpc/'
$client = new xmlrpc_client($server_url.'common');
$msg = new xmlrpcmsg('login');
$msg->addParam(new xmlrpcval($db, "string"));
$msg->addParam(new xmlrpcval($user, "string"));
$msg->addParam(new xmlrpcval($pass, "string"));
$res = &$client->send($msg);
if(!$res->faultCode()){
$val = $res->value();
$id = $val->scalarval();
if (empty($id)){
echo "Connection error = ";
exit;
}
else
{
$client2 = new xmlrpc_client($server_url.'object');
$key = array(new xmlrpcval(array(new xmlrpcval("code", "string"), new xmlrpcval("=", "string"), new xmlrpcval($post['country'], "string")),"array"),);
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($db, "string"));
$msg->addParam(new xmlrpcval($id, "int"));
$msg->addParam(new xmlrpcval($pass, "string"));
$msg->addParam(new xmlrpcval("res.country","string"));
$msg->addParam(new xmlrpcval("search", "string"));
$msg->addParam(new xmlrpcval($key, "array"));
$msg->addParam(new xmlrpcval(0, "int"));
$msg->addParam(new xmlrpcval(1, "int"));
$res = &$client2->send($msg);
$val = $res->value()->scalarval();
$countryId = $val[0]->scalarval();
$val = array ("name" => new xmlrpcval($post['company'],"string"),
"email_from" => new xmlrpcval($post['email'], "string"),
"phone" => new xmlrpcval($post['phone'], "string"),
"partner_name" => new xmlrpcval($post['name'], "string"),
"function" => new xmlrpcval($post["jobtitle"], "string"),
"zip" => new xmlrpcval($post['zip'], "string"),
"stage_id" => new xmlrpcval(2, "int"),
"city" => new xmlrpcval($post['city'], "string"),
"country_id" => new xmlrpcval($countryId, "int"),
"state" => new xmlrpcval("draft", "string"),
"user_id" => new xmlrpcval(false, "boolean"),
"description" => new xmlrpcval("No.of Employees: ".$post['employees']."\nState: ".$post['state']."\nIndustry: ".$post['industry']."\nAbout: ".$post['about'], "string")
);
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($db, "string"));
$msg->addParam(new xmlrpcval($id, "int"));
$msg->addParam(new xmlrpcval($pass, "string"));
$msg->addParam(new xmlrpcval("crm.lead", "string"));
$msg->addParam(new xmlrpcval("create", "string"));
$msg->addParam(new xmlrpcval($val, "struct"));
$res2 = &$client2->send($msg);
if(!$res2->faultCode())
{
$readVal = $res2->value()->scalarval();
if (!empty($readVal))
{
$val = array ( "description" => new xmlrpcval("About: ".$post['about']),
"model_id" => new xmlrpcval(276, "int"),
"res_id" => new xmlrpcval($readVal,"int"),
"email_from" => new xmlrpcval($post['email'], "string"),
"email_to" => new xmlrpcval("sales@openerp.com", "string")
);
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($db, "string"));
$msg->addParam(new xmlrpcval($id, "int"));
$msg->addParam(new xmlrpcval($pass, "string"));
$msg->addParam(new xmlrpcval("crm.case.history", "string"));
$msg->addParam(new xmlrpcval("create", "string"));
$msg->addParam(new xmlrpcval($val, "struct"));
$res2 = &$client2->send($msg);
//echo "<br />Successfully created lead";
echo "<br /><h3>Thank You for your interest in openerp, we'll respond to your request shortly.</h3><br />";
if(strstr($post["about"],"Book")) {
echo '<script>window.location="http://www.openerp.com/index.php?option=com_content&id=54"</script>';
}
}
else
{
echo "<br />Lead is not created";
}
}
else
{
echo "<br />Problem in message sending for create lead";
}
}
}
else
{
echo "<br />Connection not established";
}
}
}
if(isset($_POST['country']) && $_POST['country'] != '') {
$arrData = array();
$arrData = array_merge($arrData, (array)$_POST);
$cnt = new Contact('sales5@openerp.com', 'Country: '.$arrData['country']. ' About: ' .$arrData['about']);
/* This function use for sending mail on perticular mail account */
/*$cnt->mailTo($arrData); */
/* This function use ceating lead in crm of opener erp database */
//Change to fit your configuration
$cnt->xmlCallTo('admin', 'a', 'db_1', 'http://localhost:8069/xmlrpc/', $arrData);
}
else {
echo 'please fill the form at <a href="form.php">form.php</a>';
}
exit;
to=$to;
$this->subject=$sub;
}
函数xmlCallTo($usr、$password、$database、$server、$post)
{
$user=$usr;
$pass=$password;
$db=$database;
$server\u url=$server;//'http://localhost:8069/xmlrpc/'
$client=newxmlrpc_客户端($server_url.'common');
$msg=newxmlrpcmsg('login');
$msg->addParam(新的xmlrpcval($db,“string”);
$msg->addParam(新的xmlrpcval($user,“string”);
$msg->addParam(新的xmlrpcval($pass,“string”);
$res=&$client->send($msg);
如果(!$res->faultCode()){
$val=$res->value();
$id=$val->scalarval();
if(空($id)){
echo“连接错误=”;
出口
}
其他的
{
$client2=新的xmlrpc_客户端($server_url.'object');
$key=array(新的xmlrpcval(array(新的xmlrpcval(“代码”、“字符串”)、新的xmlrpcval(“=”、“字符串”)、新的xmlrpcval($post['country']、“字符串”)、“数组”)、);
$msg=新的xmlrpcmsg('execute');
$msg->addParam(新的xmlrpcval($db,“string”);
$msg->addParam(新的xmlrpcval($id,“int”);
$msg->addParam(新的xmlrpcval($pass,“string”);
$msg->addParam(新的xmlrpcval(“res.country”,“string”);
$msg->addParam(新的xmlrpcval(“搜索”、“字符串”);
$msg->addParam(新的xmlrpcval($key,“array”);
$msg->addParam(新的xmlrpcval(0,“int”);
$msg->addParam(新的xmlrpcval(1,“int”);
$res=&$client2->send($msg);
$val=$res->value()->scalarval();
$countryId=$val[0]->scalarval();
$val=array(“name”=>newxmlrpcval($post['company'],“string”),
“email_from”=>newxmlrpcval($post['email'],“string”),
“phone”=>新的xmlrpcval($post['phone'],“string”),
“合作伙伴名称”=>newXMLRPCVAL($post['name'],“string”),
“function”=>newXMLRPCVAL($post[“jobtitle”],“string”),
“zip”=>新的xmlrpcval($post['zip'],“string”),
“stage_id”=>新的xmlrpcval(2,“int”),
“城市”=>新的xmlrpcval($post['city'],“string”),
“country_id”=>新的xmlrpcval($countryId,“int”),
“state”=>新的xmlrpcval(“草稿”、“字符串”),
“user_id”=>新的xmlrpcval(false,“boolean”),
“description”=>新xmlrpcval(“员工数量:.$post['Employees']”\n状态:.$post['state']。\n行业:.$post['industry']。\n内容:.$post['about'],“字符串”)
);
$msg=新的xmlrpcmsg('execute');
$msg->addParam(新的xmlrpcval($db,“string”);
$msg->addParam(新的xmlrpcval($id,“int”);
$msg->addParam(新的xmlrpcval($pass,“string”);
$msg->addParam(新的xmlrpcval(“crm.lead”、“string”);
$msg->addParam(新的xmlrpcval(“创建”、“字符串”);
$msg->addParam(新的xmlrpcval($val,“struct”);
$res2=&$client2->send($msg);
如果(!$res2->faultCode())
{
$readVal=$res2->value()->scalarval();
如果(!empty($readVal))
{
$val=array(“description”=>newxmlrpcval(“About:”.$post['About']),
“model_id”=>新的xmlrpcval(276,“int”),
“res_id”=>新的xmlrpcval($readVal,“int”),
“email_from”=>newxmlrpcval($post['email'],“string”),
“通过电子邮件发送至”=>新的xmlrpcval(”sales@openerp.com“,“字符串”)
);
$msg=新的xmlrpcmsg('execute');
$msg->addParam(新的xmlrpcval($db,“string”);
$msg->addParam(新的xmlrpcval($id,“int”);
$msg->addParam(新的xmlrpcval($pass,“string”);
$msg->addParam(新的xmlrpcval(“crm.case.history”,“string”);
$msg->addParam(新的xmlrpcval(“创建”、“字符串”);
$msg->addParam(新的xmlrpcval($val,“struct”);
$res2=&$client2->send($msg);
//echo“
已成功创建lead”;
echo“
感谢您对openerp的兴趣,我们将很快回复您的请求。
”;
if(strstr($post[“about”],“Book”)){
echo'窗口。位置=”http://www.openerp.com/index.php?option=com_content&;id=54“;
}
}
其他的
{
echo“
未创建潜在客户”;
}
}
其他的
{
echo“
为创建lead发送消息时出现问题”;
}
}
}
其他的
{
echo“
未建立连接”;
}
}
}
如果(isset($\u POST['country'])和&$\u POST['country'])!=“”){
$arrData=array();
$arrData=array\u merge($arrData,(array)$\u POST);
$cnt=新联系人('sales5@openerp.com“,”国家:“.$arrData['Country'].”关于:“.$arrData['About']);
/*此函数用于在特定邮件帐户上发送邮件*/
/*$cnt->mailTo($arrData)*/
/*此功能在opener erp数据库的crm中使用ceating lead*/
//更改以适应您的配置
$cnt->xmlCallTo('admin','a','db_1','http://localhost:80
<?php
include("xmlrpc.inc");
//Change to fit your configuration
$user = "admin";
$password = "a";
$db = "db_1";
$serverUri = "http://localhost:8069/xmlrpc/";
$client = new xmlrpc_client($serverUri.'common');
$msg = new xmlrpcmsg('login');
$msg->addParam(new xmlrpcval($db, "string"));
$msg->addParam(new xmlrpcval($user, "string"));
$msg->addParam(new xmlrpcval($password, "string"));
$res = &$client->send($msg);
if(!$res->faultCode()){
$id = $res->value()->scalarval();
$client = new xmlrpc_client($serverUri.'object');
$key = array(new xmlrpcval(array(new xmlrpcval("id", "string"),
new xmlrpcval(">", "string"),
new xmlrpcval(0, "int")),"array"),);
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($db, "string"));
$msg->addParam(new xmlrpcval($id, "int"));
$msg->addParam(new xmlrpcval($password, "string"));
$msg->addParam(new xmlrpcval("res.country","string"));
$msg->addParam(new xmlrpcval("search", "string"));
$msg->addParam(new xmlrpcval($key, "array"));
$msg->addParam(new xmlrpcval(0, "int"));
$msg->addParam(new xmlrpcval(0, "int"));
$msg->addParam(new xmlrpcval("id ASC", "string"));
$res = &$client->send($msg);
if(!$res->faultCode())
{
$val = $res->value()->scalarval();
$ides = array();
for ($i=0 ; $i<count($val); $i++)
{
array_push($ides, new xmlrpcval($val[$i]->scalarval(), "int"));
}
$client = new xmlrpc_client($serverUri.'object');
$fields = array(new xmlrpcval("code", "string"), new xmlrpcval("name", "string"));
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($db, "string"));
$msg->addParam(new xmlrpcval($id, "int"));
$msg->addParam(new xmlrpcval($password, "string"));
$msg->addParam(new xmlrpcval("res.country","string"));
$msg->addParam(new xmlrpcval("read", "string"));
$msg->addParam(new xmlrpcval($ides, "array"));
$msg->addParam(new xmlrpcval($fields, "array"));
$res = &$client->send($msg);
if (!$res->faultCode())
{
$val = $res->value()->scalarval();
$select ='<select class="inputbox required" name="country" id="country" >
<option value="" selected="selected"> -- Select an Option -- </option>';
for ($i=0; $i<count($val);$i++)
{
$field = $val[$i]->scalarval();
$select .= '<option value="'.$field['code']->scalarval().'">'.$field['name']->scalarval().'</option>';
}
$select .= '</select>';
echo $select;
}
else
{
echo "Country not getting";
}
}
else
{
echo "Country list id empty";
}
}
else
{
echo "connection not establish";
}
?>
<html>
<head>
<title>Contact form</title>
</head>
<body>
<h4>Contact Form</h4>
<form method="post" action="crmlead.php">
<label for="firstname">Firstname</label>
<input type="text" name="name" value="" id="firstname" class="required text" title="Please, fill in your firstname" data-required="true"><br />
<label for="company">Company</label>
<input type="text" name="company" value="" id="company" class="required text" title="Please, fill in your company name" data-required="true"><br />
<label for="jobtitle">Jobtitle</label>
<input type="text" name="jobtitle" value="" id="jobtitle" class="required text" title="Please, fill in your job title" data-required="true"><br />
<label for="email">Email</label>
<input type="text" name="email" value="" id="email" class="required email text" title="Please, enter a valid email address" data-required="true"><br />
<label for="phone">Phone</label>
<input type="text" name="phone" value="" id="phone" class="required phone text" title="Please use international format (eg: +32...)" data-required="true">
<label for="city">City</label>
<input type="text" name="city" value="" id="city" class="required text" title="Please, fill in your city" data-required="true"><br />
<label for="zip">Zipcode</label>
<td><input type="text" name="zip" value="" id="zip" class="required text" title="Please, fill in your zipcode" data-required="true"><br />
<label for="state">State</label><input type="text" name="state" value="" id="state" class="text" title="Please, fill in your state"> <br />
<label> Country : <?php include('countrylist.php'); ?></label> <br />
<label for="employees">No.of employees</label>
<select class="required" name="employees" title="Please, select the No. of employees" data-required="true">
<option value=""> -- select an option -- </option>
<option value="1-5">1-5</option>
<option value="5-10">5-10</option>
<option value="10-20">10-20</option>
<option value="20-100">20-100</option>
<option value="100-500">100-500</option>
<option value="500+">500+</option>
</select><br />
<label for="industry">Industry expertise</label>
<select class="required select" name="industry" title="Please, select an industry" data-required="true">
<option value=""> -- select an option -- </option>
<option value="auction">Auction Houses</option>
<option value="bank">Bank</option>
<option value="distribution">Distribution</option>
<option value="education">Education</option>
<option value="entertainment">Entertainment</option>
<option value="erp_integrator">ERP Integrator</option>
<option value="food_industries">Food industries</option>
<option value="hotels_restaurants">Hotels & restaurants</option>
<option value="insurance">Insurance</option>
<option value="manufacturing">Manufacturing</option>
<option value="non_profit">Non-Profit</option>
<option value="public">Public</option>
<option value="services">Services</option>
<option value="telecommunication">Telecommunication</option>
<option value="others">Others</option>
</select><br />
<p>
<label> About : <textarea name="about"></textarea></textarea></label>
</p>
<p>
<input type="submit" value="Send"/> <input type="reset" />
</p>
</form>
</body>
</html>