Facebook Platform for Mobile: SMS
From Facebook Developer Wiki
Facebook Platform for Mobile provides applications with methods to directly interact with Facebook users through SMS (Short Message Service) interaction. This includes sending messages to the user and responding to messages from the user via text message.
Contents |
Policies
- Users must explicitly opt in to receive SMS from the application.
- Online opt-in through the extended permissions authorization page. In order to enable SMS support for a user, the application would direct the user to http://m.facebook.com/authorize.php?api_key=YOUR_API_KEY&v=1.0&ext_perm=sms
- Offline opt-in through SMS directly, by sending a query to an application which they have not already installed as described below in the user generated messages section. If the user is not already registered for Facebook Mobile or the application, the request is cached and forwarded when the user validates the action.
- Design Restrictions:
- An application has to explicitly register for SMS capabilities. This is identified by "mobile capabilities" indicators on the application properties section.
- Single- v. Multiple-User Routing: Facebook prohibits multiple user-routing. Each message must be sent to one user only.
- Throttling: Facebook has implemented the following throttling restrictions on the ability of applications to send SMS. Applications will be limited to a global limit that equals the sum of 1 MT (Mobile Terminated, or a message sent to a mobile phone) per user that has opted to receive SMS from the app each day. In response to an MO (Mobile Originated, or a message sent by a mobile phone) sent directly to the application a response of 1 MT is allowed to which this limit does not apply.
- Application messages are subject to all user defined global restrictions on SMS notifications such as time of day and daily limiting. These restrictions do not apply in the case of a response to a user generated message.
- Application-generated SMS messages are only allowed to refer to m.facebook.com based urls.
- Opt-out Policies.
- Users can disable SMS for an app at any time from the Facebook Mobile Control Panel or the application's Edit Settings page.
- Users can also disable SMS entirely by any of the following methods:
- Replying "Stop" or "Off" in response to any message originating from a Facebook application.
- Turning Mobile Texts to "Off" from the Facebook Mobile Control panel.
- Removing the Facebook Mobile Application.
API
Receiving User Generated Messages
A user can send your application a query directly by issuing a text message of the form to the FBOOK shortcode (32665):
In addition, if your application previously sent that user a message and requested a session, any user response to that message will be forwarded to your application directly. This happens through a POST method to your application's callback URL with the following parameters:
-
fb_sig_sms- set to 1 to indicate this is an SMS callback -
fb_sig_user- the user ID that triggered the callback -
fb_sig_message- the message string (stripped of the header mentioned above) -
fb_sig_sms_sid- the session ID to be used if the application wishes to respond to the message. A session ID is only unique in the context of its corresponding user ID. -
fb_sig_sms_new_user- set to 1 if the user has just recently added the application through offline SMS.
Your application then has a window 1 minute in length in which it can respond to the message. After the minute times out, the session expires.
Sending Application Generated Messages
In order for your application to send an SMS message, the user must grant your application the sms extended permission.
Then call sms.canSend to verify whether the user has enabled SMS for your application.
To send the message, call sms.send.
Workflow
Notification
- App invokes SMS.send without requesting a session
- Message sent to user
Conversation
- App invokes SMS.send and requests a session
- Message is sent to the user
- App retrieves session id to be used to track future state
- User may or may not respond to message, and cycle continues
User Query
- User sends message to application by app_canvas_name <query> to FBOOK (32665).
- Message is posted to application callback url with session id
- Application replies within the timeout using the given session id
- Message sent to user
Installation
- User sends a message to an application that they have either not already installed, or for which they have not authorized SMS access
- Message is cached and the user is sent a confirmation SMS
- If the user confirms the action, the cached message is forwarded to the application and the application is installed and enabled for SMS for the user, otherwise no action takes place.
