2016-04-18 11 views
3

は、私はこのコードは、サーバーFacebookのメッセンジャーボットウェブフック問題

app.post('/bot', function (req, res) { 
    console.log('post bot: ' + req); 
    var messaging_events = req.body.entry[0].messaging; 
    for (var i = 0; i < messaging_events.length; i++) { 
    var event = req.body.entry[0].messaging[i]; 
    var sender = event.sender.id; 
    if (event.message && event.message.text) { 
     text = event.message.text; 
     console.log('text received: ' + text); 
     sendTextMessage(sender, "Text received, echo: "+ text.substring(0, 200)); 
    } 
    } 
    res.sendStatus(200); 
}); 

上で実行され、このメッセージ

Your Webhooks subscription callback URL has not been accepting updates.

We've noticed that your Webhooks subscription for callback URL https://trololo.herokuapp.com/bot has not been accepting updates for at least 16 minutes. Please verify that your callback server is functioning so you may continue to receive updates. If you need to update your callback URL, see https://developers.facebook.com/docs/graph-api/reference/app/subscriptions#update

If your callback URL continues to fail to accept updates for 8 hours straight, we will disable your subscription. To reactivate the subscription, make a POST request with the same parameters, and it will be reactivated.

を受けた。しかしreq.bodyが定義されていないので、それは失敗します。 REQのparamsが、それはこのエラーになりますので、また何JSONではありません:

TypeError: Converting circular structure to JSON

REQのみを示し、[オブジェクトのオブジェクト]といただきました物体内部の私は考えています。 .toStringも機能しません。

私は完全なガイドを2回作った。私は問題は、一部から来ると思うFacebookのページは、Facebookのアプリケーションに接続する必要があります。私はこれをcurl -ik -X POST "https://graph.facebook.com/v2.6/me/subscribed_apps?access_token=<mytoken>"で手伝ってください。どんな反応も高く評価されます。ここで

あなたは、あなたがnode-wit/examples/messenger.js上のプログラムのサンプルについてのコメントを見れば、私は多分あなたはJSONボディパーサーにbody-parser

を逃している...それは依存関係の問題だと思うデモログ error logs

答えて

1

ですあなたには、いくつかのDEPSをインストールする必要があることが表示されます。

プロジェクトディレクトリに、試してみてください。

npm install body-parser express request 

見てください:https://www.youtube.com/watch?v=zFO1cRr5-qY ...私は彼らがこの問題とあなたが見つけるかもしれない他のものを正確に解決したと思います。