我正在按照以下指南尝试创建 webhook : https://developers.facebook.com/docs/messenger-platform/getting-started/webhook-setup
一切都很好,直到我尝试使用 cmd 发送此 cURL 请求以测试 webhook :-
curl -H "Content-Type: application/json" -X POST "localhost:1337/webhook" -d '{"object": "page", "entry": [{"messaging": [{"message": "TEST_MESSAGE"}]}]}'
应该给我类似的东西:-
相反,在发送 cURL 请求后,我在运行节点过程的命令行中收到此错误:-
SyntaxError: Unexpected token ' in JSON at position 0
at JSON.parse (<anonymous>)
at createStrictSyntaxError (C:\Users\Fuad Hasan\Desktop\messenger-webhook\node_modules\body-parser\lib\types\json.js:158:10)
at parse (C:\Users\Fuad Hasan\Desktop\messenger-webhook\node_modules\body-parser\lib\types\json.js:83:15)
at C:\Users\Fuad Hasan\Desktop\messenger-webhook\node_modules\body-parser\lib\read.js:121:18
at invokeCallback (C:\Users\Fuad Hasan\Desktop\messenger-webhook\node_modules\raw-body\index.js:224:16)
at done (C:\Users\Fuad Hasan\Desktop\messenger-webhook\node_modules\raw-body\index.js:213:7)
at IncomingMessage.onEnd (C:\Users\Fuad Hasan\Desktop\messenger-webhook\node_modules\raw-body\index.js:273:7)
at IncomingMessage.emit (events.js:205:15)
at endReadableNT (_stream_readable.js:1137:12)
at processTicksAndRejections (internal/process/task_queues.js:84:9)
在运行 cURL 请求的命令行中出现此错误:-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>SyntaxError: Unexpected token ' in JSON at position 0<br> at JSON.parse (<anonymous>)<br> at createStrictSyntaxError (C:\Users\Fuad Hasan\Desktop\messenger-webhook\node_modules\body-parser\lib\types\json.js:158:10)<br> at parse (C:\Users\Fuad Hasan\Desktop\messenger-webhook\node_modules\body-parser\lib\types\json.js:83:15)<br> at C:\Users\Fuad Hasan\Desktop\messenger-webhook\node_modules\body-parser\lib\read.js:121:18<br> at invokeCallback (C:\Users\Fuad Hasan\Desktop\messenger-webhook\node_modules\raw-body\index.js:224:16)<br> at done (C:\Users\Fuad Hasan\Desktop\messenger-webhook\node_modules\raw-body\index.js:213:7)<br> at IncomingMessage.onEnd (C:\Users\Fuad Hasan\Desktop\messenger-webhook\node_modules\raw-body\index.js:273:7)<br> at IncomingMessage.emit (events.js:205:15)<br> at endReadableNT (_stream_readable.js:1137:12)<br> at processTicksAndRejections (internal/process/task_queues.js:84:9)</pre>
</body>
</html>
curl: (6) Could not resolve host: page,
curl: (6) Could not resolve host: entry
curl: (3) [globbing] bad range specification in column 2
curl: (3) [globbing] bad range specification in column 2
curl: (3) [globbing] unmatched close brace/bracket in column 13
为什么会出现此错误?我尝试用Google搜索它,但没有运气。我对JSON文件也不了解,所以请帮帮我。
注意:我是这方面的超级初学者,所以请放轻松我吧