我有一个php页面,列出了不同用户的智能工作表内容。它用作业名称、开始日期和交付日期等信息填充表格。但我也希望用户能够在工作完成时勾选复选框。
选中复选框后,会调用另一个(非常初级的)页面将新值存储到智能工作表中。
这个页面是由一个基本的get命令触发的,如下所示:
http://myurl/index.php?colId=XXX&rowId=YYY&status=已检查
其中使用的变量为:
colId=The ID of the column to be changed
rowId=The ID of the row to be changed
checked=If the checkbox is checked
status=The value stored in the smartheet
(1 for a checked checkbox and '' for an unchecked checkbox)
这是index.php的代码(从这篇文章中被盗):
$inputToken = "myInputToken";
$colId=$_GET['colId'];
$rowId=$_GET['rowId'];
if($_GET['status'] == "checked"){
$status='1';
}
else{
$status='';
}
$ch = curl_init("https://api.smartsheet.com/1.1/row/".$rowId./cells");
$header = array("Authorization: Bearer ".$inputToken,
"Content-Type: application/json",
"Assume-User: myName%40myDomainName");
$fields = '[{"columnId": $colId, "value": "'.$status.'", "displayValue": "'.$status.'"}]';
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
$result = curl_exec($ch);
print_r($result);
"输入令牌"由与"假定用户"电子邮件相同的电子邮件生成。当我登录时,我可以更改常规智能工作表中的值。但当我运行网页时,我仍然会遇到这个错误:
{"errorCode":1030,"message":"You are unable to assume the user specified."}
有人知道我做错了什么吗?
任何帮助都将不胜感激!
以用户身份登录有两种方法。首先,您可以使用该用户帐户的令牌直接登录。标题看起来像:
$header = array('Authorization: Bearer '.$userToken,
"Content-Type: application/json");
第二个选项是使用管理员帐户以其他用户身份登录。要做到这一点,您可以使用假定用户头和管理员的令牌。标题看起来像:
$header = array('Authorization: Bearer '.$adminToken,
'Content-Type: application/json',
'Assume-User: someUser%40someDomain.com');
假设用户的文档可以在这里找到。