I was wondering if it is possible to have a messenger bot send you a youtube video link and generate a playable video inside messenger the same way you can if you paste a link inside the messenger. Right now my bot can send a message with a youtube link but it just sends it as text it doesn't generate a video recognizing the title, description etc. Any help would be appreciated.
You can also send by OpenGraph. It will automatically display the video inside m.me chat window but in mobile iOS app, currently it redirects to youtube page:
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"USER_ID"
},
"message":{
"attachment":{
"type":"template",
"payload":{
"template_type":"open_graph",
"elements":[
{
"url":"https://www.youtube.com/watch?v=y9A1MEbgLyA"
}
]
}
}
}
}' "https://graph.facebook.com/v2.6/me/messages?access_token=$TOKEN"
As of 7/1/2016, the new API docs allow video messages assuming you've got the url of the actual mp4 file. For a youtube video, that url is (purposefully) not easy to get to. There are some tools, like youtube-dl, that will get the url of a file from YouTube and it would be possible to use that url with a facebook video message. This setup is of course assuming facebook does not have any blocking in place for youtube video links.
Another approach would be to build your own combo thumbnail/video link message using a "generic template" facebook message.
You can send Video with size <= 30MB with following code.
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"USER_ID"
},
"message":{
"attachment":{
"type":"video",
"payload":{
"url":"direct_url_to_video",
"is_reusable":true
}
}
}
}' "https://graph.facebook.com/v2.6/me/messages?access_token=ACCESS_TOKEN"
After that, above command will return "attachment_id" of video From now, you can send video with attachment_id and never expire.
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"USER_ID"
},
"message":{
"attachment":{
"type":"video",
"payload":{
"attachment_id": "<attachment_id_here"
}
}
}
}' "https://graph.facebook.com/v2.6/me/messages?access_token=ACCESS_TOKEN"
I found a temporary solution (videos may expire). Try this site: http://catchvideo.net/. It will give you the playable video link you can use your bot to send in the messenger as an attachment. Hope this helps!
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"USER_ID"
},
"message":{
"attachment":{
"type":"video",
"payload":{
"url":"THE_LINK_FROM_WEBSITE_ABOVE" (example: https://redirector.googlevideo.com/videoplayback?itag=18.....)
}
}
}
}' "https://graph.facebook.com/v2.6/me/messages?access_token=ACCESS_TOKEN"
© 2022 - 2024 — McMap. All rights reserved.