我有这个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);
}
我在记录的回复中收到以下错误
回复:{“错误”:{“code”:“user_not_found”,“description”:“找不到用户”}}
我已使用smooch.io
提供的凭据验证了我的签名https://jwt.io/我怀疑这是{smoochId | userId}值?我刚从浏览器的URL复制了这些随机字符(5790bff5237cbc5d00b10a17),我假设这是我的用户ID。请告知我如何获取smoochID或userID。谢谢!
答案 0 :(得分:1)
5790bff5237cbc5d00b10a17是您的应用ID,而非您的用户ID。要获取用户ID,您必须先初始化一个: