2017-01-07 2 views
0

내 봇에서 사용자에게 위치를 보내려고하십니까? 그게 허용됩니까? 이 경우, 내가 JSON 형식이 정확이 내 코드에 무슨 일이고 나는페이스 북의 메신저로 위치 보내기

오류 : {메시지 : '(# 100) 지원되지 않는 첨부 파일 유형',

2017-01-07T20 : 02 : 00.841002 + 00 : 00 앱 [web.1] : 형식 : 02 : 'OAuthException'

2017-01-07T20

+ 00.841004 00 : 코드 : [web.1] 00 앱 100

2017-01-07T20 : 02 : 00.841004 + 00 : error_subcode : 2,018,046,

2017-01-07T20 : 02 : 00.841005 + 00 : 00 앱 [web.1] fbtrace_id [web.1] 00 앱 : 누군가가 컨텍스트를 제공 할 수 있다면 'CObB3 + 0fgMw'} 오류 는

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

이 아니오 봇은 "type": "location",로 첨부 파일 유형과 위치를 공유 할 수 없습니다 좋은 것입니다. 오류 메시지는 명확하게 Unsupported attachment type이라고합니다.

대신 할 수있는 옵션 중 하나는 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

감사합니다, 스리 람

관련 문제