Custom URI Schemes for the Facebook Messenger

这一生的挚爱 提交于 2019-11-26 22:08:58

After unsuccessfully searching for this information, I've decided to make a list of my own. Below is what I managed to gather so far, along with a few explanations:

This is updated for version 141.0.0.25.76 (October 21, 2017).

fb-messenger://accounts
fb-messenger://active_now
fb-messenger://addcard
fb-messenger://addmembers
fb-messenger://android_date_time
fb-messenger://android_storage
fb-messenger://autocompose
fb-messenger://autocompose_payment
fb-messenger://bots/get_started/?page_id=%s&cta_id=%s
fb-messenger://business
fb-messenger://business/
fb-messenger://business_extensions
fb-messenger://buy/mc?item_id={#%s}
fb-messenger://callsearch
fb-messenger://commerce/
fb-messenger://compose
fb-messenger://contactmigration
fb-messenger://contacts
fb-messenger://contacts/add_contacts
fb-messenger://contactuploadoptin
fb-messenger://direct_share
fb-messenger://drawoverotherapps
fb-messenger://games
fb-messenger://groupcompose
fb-messenger://groupstab
fb-messenger://groupthreadfbid/
fb-messenger://groupthreadfbid/%s
fb-messenger://ig_contact_import
fb-messenger://installupdate
fb-messenger://instant_article/?article_id=
fb-messenger://instant_article/?article_id=%s
fb-messenger://invite
fb-messenger://join_request
fb-messenger://mai
fb-messenger://messagerequests
fb-messenger://messagesearch
fb-messenger://montage
fb-messenger://montage_composer
fb-messenger://montage_mediapicker
fb-messenger://montageaudiencepicker
fb-messenger://montagecomposer
fb-messenger://networkempathy
fb-messenger://new
fb-messenger://newuser/
fb-messenger://newuser/signup?provider_name=%s&provider_page_fbid=%s
fb-messenger://nfc
fb-messenger://omni_m
fb-messenger://opengrouppreview
fb-messenger://opengrouppreview?group_preview_hash=
fb-messenger://optimistic
fb-messenger://optimistic/%s
fb-messenger://payments
fb-messenger://payments/
fb-messenger://platform
fb-messenger://platform/cta/postback/?cta_id=%s
fb-messenger://platform/share/?cta_id=%s
fb-messenger://ride_map/{%s}
fb-messenger://roomcompose
fb-messenger://rtccall
fb-messenger://sampleflows
fb-messenger://settings
fb-messenger://settings/datasaver
fb-messenger://settings/messengeronlybackup
fb-messenger://settings/montage
fb-messenger://settings/notifications
fb-messenger://settings/people
fb-messenger://settings/phoneevents
fb-messenger://settings/profilepicture
fb-messenger://settings/tincan
fb-messenger://share                    < Used for sharing multimedia, contains 
                                          several extras. See more info below.
fb-messenger://sms
fb-messenger://sms/
fb-messenger://sms/%s
fb-messenger://sms-bridge
fb-messenger://sms-takeover
fb-messenger://sms-takeover/nux?context=%s
fb-messenger://sms-takeover/nux?context=%s&thread_id=%s
fb-messenger://sms-takeover/sms_anonymous_chat_head
fb-messenger://stickerstore
fb-messenger://thread/                  < Deprecated
fb-messenger://threadkeystring
fb-messenger://threads
fb-messenger://threadsettings
fb-messenger://user
fb-messenger://user/
fb-messenger://user/%s                  < Opens chathead/conversation with user %s, where
                                          %s is the numeric fb user id. Using a username 
                                          string here crashes the orca app.
fb-messenger://user/%s?ref=%s&ref_source=%s
fb-messenger://verifyphonenux
fb-messenger://voip
fb-messenger://wave

Here are some URI schemes whose purpose in this app I don't know:

  • fb:// - see possible URIs of this scheme here.
  • fb-work://
  • fbinternal://
  • fb-messenger-secure://
  • dialtone://

Investigation of fb-messenger://share (from older version of this post - may be invalid):

  • Has a StringExtra called ShareType that can be: ShareType.invite, ShareType.forward, ShareType.regular.
  • Has an optional (?) StringExtra called ShareType.invitedUser.
  • Has an optional (?) StringExtra called ShareType.invitedUserDisplayName.
  • Has an optional (?) StringExtra called ShareType.inviteEntryPoint.
  • Has an optional (?) StringExtra called ShareType.invitesSentBroadcastAction.
  • (several others)

In the case of ShareType.forward:

  • Has an Extra with the tag "attachment" OR "message".
  • Has an Extra with the tag "trigger".

Extra fields of a share Intent (tag : type):

  • android.intent.extra.TEXT : String
  • attachment : Parcelable
  • message : Parcelable
  • page_name : String
  • page_post_id : String
  • page_target : Long
  • send_as_message_entry_point : String
  • share_attachment_url : String
  • share_caption : String
  • share_description : String
  • share_fbid : String
  • share_link_url : String
  • share_media_url : String
  • share_return_to_fb4a : Boolean
  • share_robotext : String
  • share_story_url : String
  • share_title : String
  • ShareType : String
  • target_recipients : StringArray
  • title : String
  • trigger : String

The required functionality may be achieved by using fb-messenger://user/{user-id} instead of fb-messenger://user-thread/{user-id}.

Note that {user-id} is the user's global numeric ID (e.g. for Zuck it's 4), which can be obtained (as of Nov. 2015) by parsing the html document that corresponds to the person's user name (e.g. for Zuck it's https://www.facebook.com/zuck) and extracting the "entity_id" that is found inside.

According to my latest test, app-scoped user IDs, which are usually the IDs available to developers, do not work for this!

Below is a python3 script that extracts the global ID for a known username (credit: Paul Schreiber):

#!/usr/bin/python

import requests
import re

url = 'https://www.facebook.com/zuck'
idre = re.compile('"entity_id":"([0-9]+)"')
page = requests.get(url)
print(idre.findall(page.content.decode()))

Alternatively, this site can be used to achieve the same thing.

Please also note that this method is not officially supported and might even get your app banned by FB.

With current version Facebook on android automatically ask user to open the app or open in chrome when you use their domain www.messenger.com It's better to just redirect user to this url and let facebook handle it

https://www.messenger.com/t/{username-or-page-name-here}

Intent intent;
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.messenger.com/t/{username-or-page-name-here}"));
startActivity(intent);

This simply share a link

<a href="fb-messenger://share?link=encodedLink"></a>

Using chrome intents for Android: The below code opens FB messenger if installed. Else redirects to fallback URL.

<a href="intent://user/<yourid>/#Intent;scheme=fb-messenger;package=com.facebook.orca;S.browser_fallback_url=http://yourfllbackweburl;end"> Open Messenger</a>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!