2017-01-07 10 views
0

私のボットからユーザーに場所を送信しようとしていますか?それは許されますか?もしそうであれば、私はJSON形式が正しい持っている私のコードで何が間違っていると私はFacebookメッセンジャーで場所を送信

エラーを取得する:{メッセージを:「(#100)サポートされていない添付ファイルの種類」、

2017-01-07T20:02 :00.841002 + 00:00アプリ[web.1]:タイプ: 'OAuthException'

2017-01-07T20:02:00.841004 + 00:00アプリ[web.1]:コード:100、

2017-01-07T20:02:00.841004 + 00:00 app [web.1]:error_subcode:2018046,

2017-01-07T20:02:00.841005 + 00:00 app [web.1]:fbtrace_id : 「CObB3 + 0fgMw」} エラー誰もが、それはボットが"type": "location",として添付ファイルの種類とその位置を共有することができない大きな

function sendLocationMessage(sender,event){ 



    let messageData={ 
     attachment: { 
      "type": "location", 
      "payload": { 
       "coordinates":{ 
       "lat": event.message.attachments[0].payload.coordinates.lat, 
       "long": event.message.attachments[0].payload.coordinates.long 
    } } 
} 
    } 
    request({ 
     url: 'https://graph.facebook.com/v2.6/me/messages', 
     qs: {access_token:token}, 
     method: 'POST', 
     json: { 
      recipient: {id:sender}, 
      message: messageData, 
     } 
    }, function(error, response, body) { 
     if (error) { 
      console.log('Error sending messages: ', error) 
     } else if (response.body.error) { 
      console.log('Error: ', response.body.error) 
     } 
    }) 
} 

答えて

3

号であろうコンテキストを提供することができる場合。エラーメッセージは、それを明確に呼び出しますUnsupported attachment type

あなたができるオプションの1つは、Googleマップ(静的)のリンクを共有することです。

messageData = { "attachment": { "type": "template", "payload": { "template_type": "generic", "elements": [{ "title": 'Location Shared By Bot', "subtitle": "Location Subtitle", "image_url": https://maps.googleapis.com/maps/api/staticmap?key= + "YOUR_GMAPS_TOKEN" + "&markers=color:red|label:B|" + lat + "," + long + "&size=360x360&zoom=13" }] } }

参考:メッセンジャーは、APIリファレンスを送る - https://developers.facebook.com/docs/messenger-platform/send-api-reference

おかげで、 スリラム

関連する問題