问题描述
这是我的 php 代码响应,但我收到“来自 webhook 的错误无效响应:无法将 JSON 转换为 ExecuteHttpResponse”。
这是生成 JSON 响应的 webhook 代码,但 google 使用此返回 json 抛出无效错误:
$method = $_SERVER['REQUEST_METHOD'];
if($method == 'POST')
{
$requestBody = file_get_contents('php://input');
$json = json_decode($requestBody,true,512,JSON_BIGINT_AS_STRING);
$customer_name = $json["requestJson"]["intent"]["params"]["customer_name"]["original"];
$returnText="Customer name is $customer_name"
$response = new \stdClass();
$response->speech = $returnText;
$response->displayText = $returnText;
$response->source = "webhook";
echo json_encode($response);
}
带有无效错误的 webhook 响应来自 webhook 的无效响应:无法将 JSON 转换为 ExecuteHttpResponse
"responseJson": {
"session": {
"id": "1234"
},"textToSpeech": "bala","displayText": "bala","source": "webhook"
}
我做错了什么?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)