2017-01-07 1 views
0

Versucht, den Standort von meinem Bot an den Benutzer zu senden? Ist das erlaubt? Wenn ja, was ist falsch mit meinem Code ich das JSON-Format korrekt haben und ich bekomme dieStandort in Facebook Messenger senden

Fehler: {message: '(# 100) Nicht unterstützte Befestigungstyp',

2017-01-07T20: 02 : 00.841002 + 00: 00 app [web.1]: Typ: 'OAuthException',

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

2017-01-07T20: 02: 00.841004 + 00: 00 App [Web.1]: Fehlercode: 2018046,

2017-01-07T20: 02: 00.841005 + 00: 00 App [Web.1]: fbtrace_id : ‚CObB3 + 0fgMw‘} Fehler Wenn jemand Kontext liefern könnte, wäre es toll,

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) 
     } 
    }) 
} 

Antwort

3

Nein, der Bot nicht seine Lage mit Befestigungstyp als "type": "location", teilen können. Die Fehlermeldung ruft es deutlich Unsupported attachment type.

Stattdessen ist eine der Optionen, die Sie tun können, teilen Sie einen Link von Google Maps (statisch).

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" }] } }

Referenz: Messenger API ref - https://developers.facebook.com/docs/messenger-platform/send-api-reference

Danke, Sriram

Verwandte Themen