webservice.php Vtiger更新查询字符串php curl post [英] webservice.php Vtiger update Query String php curl post

查看:153
本文介绍了webservice.php Vtiger更新查询字符串php curl post的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道如何正确格式化vtiger中的更新查询以更新Leads模块下的记录?

Does any one know how to properly format the update query in vtiger to update a record under the Leads module?

我一直在关注这个: http://community.vtiger.com/help/vtigercrm/developers/third -party-app-integration.html

,并且已能够登录,查询和执行质询响应,但我无法获取更新功能工作,这可能是因为我不知道他们想要查询的样子。这是我在发送查询时得到的错误:

and have been able to login, query, and do the challenge response, but I have been unable to get the update function to work and it could be because I am not sure how they want the query to look. This is the error I get when I send the query:

stdClass Object ( [success] => [error] => stdClass Object ( [code] => ACCESS_DENIED [message] => Permission to perform the operation is denied for id ) )   

当前测试代码:

function updatesomeone(){
global $createduserleadnum;
global $url;
global $sessionID;
global $createduserid;


$customdata = array(
'firstname'=> 'TestAPILead2',//Update First name
'lastname'=> 'TestAPILeadLast2', //Updated Last name
'leadstatus'=> 'New',
'leadsource'=> 'Some Lead Source', //Not Real Lead source
'assigned_user_id'=> 'User-Assigned', //not real user
'cf_755'=> 'A Custom Field', // A Custom Field
'lead_no' => $createduserleadnum, Acquired from other function/stored value
);

$customdata = json_encode($customdata);
$field = array(
'operation' => 'update',
'sessionName'=> $sessionID,
'element' => $customdata
);


$fields_string;
foreach($field as $key=>$value) { global $fields_string;
$fields_string .= $key.'='.$value.'&'; }
$ch = curl_init();


curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($field));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

$result = curl_exec($ch);
$pringjson = json_decode($result);

print_r($pringjson);

}

推荐答案

想象出来。它与$ fieldstring变量相关。由于某种原因,它不是停留在函数的本地,所以它包括一些其他变量。只是改变了一个数字在最后的fieldstring变量。在最终的代码中,我将写一个更好的脚本url-ify'ing的变量。我也不得不使用给定的完整的id。无论哪种方式,它现在解决,代码工作原理。

Figured it out. It was related to the $fieldstring variable. For some reason it was not staying local to the function so it was including some other variables. just changed the fieldstring variable with a digit at the end. In the final code I will write a better script for url-ify'ing the variables. I also had to use the full id given. Either way it was resolved now and the code works as it should.

这篇关于webservice.php Vtiger更新查询字符串php curl post的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆