php - 如何在同一个 php 方程中更改参数的值
问题描述
我正在尝试更改每个“column_id”参数的“文本”参数的值。例如:
'column_id' => 'email'
'text' => 'foresthill@mailto.com
和
'column_id => 'phone'
'text' => '555-555-5555'
如果我有一个 column_id 和 text 参数,则该等式有效,但是当我尝试将第二个 column_id 'phone' 的值更改为 text 值 555-555-5555 时,电话号码会显示在“email”列中。
如何使文本值进入其自己的 column_id,如下所示:
email = example@example.com
phone = 555-555-5555.
代码:
//********************** Update Pulse Columns for a specific pulse ***********************
$put_fields = array(
//monday.com board and user id values
'board_id' => '194618490',
'column_id' => 'email1',
'pulse_id' => 197299328,
'text' => 'foresthill@mailto.com'
);
$put_fields = array(
//monday.com board and user id values
'board_id' => '194618490',
'column_id' => 'phone',
'pulse_id' => 197299328,
'text' => '555-555-5555'
);
$ch = curl_init('https://api.monday.com:443/194618490/columns/email1/text.json?api_key=api_key');
//curl_setopt($ch, CURLOPT_USERAGENT, 'ARPR');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
//curl_setopt($ch, CURLOPT_URL, URL. $api);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $put_fields);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
//$curl_result = curl_exec($ch);
//curl_close($ch);
print "<pre>";
print_r($curl_result);
print "</pre>";
解决方案
根据monday.com doc,该 api 将仅更新一列。URL 包含列名。听起来您需要两个单独的电话。
第二个$put_fields=
覆盖第一个的内容$put_fields=
。所以当它到达 curl 的时候,没有 'column_id' => 'email
.
一种方法可能是:使column_id
本身成为一个数组,例如
column_id => ['email' : theemail, 'phone': 5555555]
显然,这需要对curl_setopt($ch, CURLOPT_POSTFIELDS, $put_fields);
.
$put_fields
另一种选择,在数组中单独列出键。目前尚不清楚您为什么需要column_id
它,因为它没有被使用。
推荐阅读
- view - 业务中心创建新视图未显示在下拉列表中
- opencv - 级联分类器对不同颜色的对象不变?
- mysql - 是否有适用于 nodejs 的 AWS 原生 mysql 客户端库?
- reactjs - 反应钩子/渲染困难
- excel - VBA Office 64 位中的 CreatePipe 错误
- c++ - 通过 ROS 网络发送激光雷达数据时的 std::bad_alloc
- angularjs - Angular Schematics - 在树上应用数以千计的更改导致错误超出最大调用堆栈大小
- r - 在R中读取多个带有时间戳的csv文件
- snowflake-cloud-data-platform - 如何在 Pypika 中“最少”使用雪花?
- angular - matdialog 在某个时间尝试弹出时显示为空