我有这个 PHP webhook 页面,用于我的示例 smooch.io 应用程序,见下文。
<?php
$content = file_get_contents("php://input");
$update = json_decode($content, true);
if (!$update) {
// receive wrong update, must not happen
exit;
}
logf(json_encode($content));
/*curl https://api.smooch.io/v1/appusers/5790bff5237cbc5d00b10a17/conversation/messages \
-X POST \
-d '{"text":"Just put some vinegar on it", "role": "appMaker"}' \
-H 'content-type: application/json' \
-H 'authorization: Bearer your-jwt'
*/
$parameters["text"] = "Reply from the webhook!";
$parameters["role"] = "appMaker";
$handle = curl_init("https://api.smooch.io/v1/appusers/5790bff5237cbc5d00b10a17/conversation/messages");
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($handle, CURLOPT_TIMEOUT, 60);
curl_setopt($handle, CURLOPT_POSTFIELDS, json_encode($parameters));
curl_setopt($handle, CURLOPT_HTTPHEADER,
array("Content-Type: application/json; charset=utf-8","Authorization: Bearer ".MY_JWT)
);
$response = curl_exec($handle);
logf("response: ".$response);
$response = json_decode($response, true);
function logf($str){
$logf = "smooch.txt";
$dtnow = date("dmy H:i:s");
$logfh = fopen($logf, 'a');
$str = $dtnow." - ".$str."\n";
fputs($logfh, $str);
fclose($logfh);
}
我在记录的响应中收到以下错误
响应:{“错误”:{“代码”:“user_not_found”,“描述”:“未找到用户”}}
我已经使用 smooch.io 提供的凭据在https://jwt.io/验证了我的签名
我怀疑是这个 {smoochId|userId} 值?我刚刚从浏览器的 URL 中复制了这些随机字符 (5790bff5237cbc5d00b10a17),我假设这是我的用户 ID。请告知如何获取我的 smoochID 或用户 ID。谢谢!