21

I would like to share an url from a website (using mobile device) to facebook messenger app.

I tried to use:

FB.ui({
    method: 'send',
    link: 'http://www.nytimes.com/interactive/2015/04/15/travel/europe-favorite-streets.html',
});

But that does nothing on the mobile device. I also tried:

fb://messaging/compose/new

That did open the message dialog but I can't find an URI for sharing an url.

I wonder if this is even possible?

Christophe
  • 4,798
  • 5
  • 41
  • 83

4 Answers4

25

This is what you are looking for:

Link:

<a href="fb-messenger://share/?link= https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fsharing%2Freference%2Fsend-dialog&app_id=123456789">Send In Messenger</a>

JavaScript:

window.open('fb-messenger://share?link=' + encodeURIComponent(link) + '&app_id=' + encodeURIComponent(app_id));

Please note: This will only work on mobile devices. For more information see here:

https://developers.facebook.com/docs/sharing/messenger/web

Albab
  • 374
  • 2
  • 12
Milen Kovachev
  • 5,111
  • 6
  • 41
  • 58
11

You can use the Send Dialog, which is not supported on mobile: https://developers.facebook.com/docs/sharing/reference/send-dialog#examples

Alternative for mobile: https://developers.facebook.com/docs/sharing/messenger

andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • The alternative you propose does not compile. I get a Use of unresolved identifier 'FBSDKShareMessengerURLActionButton' error and the code won't compile. And yes, I am importing the 4.29 sdk and later. – LilMoke Jan 04 '19 at 14:18
  • that is a very specific issue, you should create a new thread for it, including all the relevant code of yours. – andyrandy Jan 06 '19 at 12:14
7

FWIW the following link, clicked on a desktop computer, will allow your user to share the link via Facebook Messenger. You have to replace app-id with the app-id of an arbitrary app of yours, created at developer.faceboook.com:

http://www.facebook.com/dialog/send?app_id=[app-id]&link=https://stackoverflow.com&redirect_uri=https://stackoverflow.com

tyrex
  • 8,208
  • 12
  • 43
  • 50
4
<a href="fb-messenger://share/?link=http://url-you-want-to-share.com&app_id=your-app-id-here">
... 
</a>

Does not seem to work on desktop, but I could be wrong.

Source: https://developers.facebook.com/docs/sharing/messenger

Versa
  • 605
  • 7
  • 11