Post-Remove Callback URL
From Facebook Developer Wiki
Contents |
Overview
The Post-Remove URL is briefly described in Creating a Platform Application. Facebook pings this URL when a user removes your application from his or her "My Applications" page. Facebook's servers POST several fields back to this URL along with a signature.
This URL cannot be your application's canvas page or a Facebook-framed page, since removing an application means the user is no longer using it within Facebook. The user does not see any content you display in this page.
POST Parameters of Ping
The following fields are sent to your Post-Remove URL in the form of a POST request. The user removing your application will not be redirected to this URL. Facebook's servers send this request in the background.
| Type | Name | Description |
|---|---|---|
int
| fb_sig_uninstall | Set to 1 to indicate the user is removing your application |
string
| fb_sig_time | A UNIX timestamp indicating when the removal occurred (e.g. 1187756160.7131)
|
int
| fb_sig_user | The uid of the person who is removing your application (e.g. 609143784)
|
string
| fb_sig_app_id | The application ID of your application that is being removed.
|
string
| fb_sig_api_key | The api_key of your application that is being removed.
|
int
| fb_sig_added | This parameter is returned with a value of 0, indicating that the application has been removed. |
string
| fb_sig_linked_account_ids | JSON-encoded array of linked account ids that were set with Connect.registerUsers. If you have previously registered a user's email address, and that user then de-authorizes your Connect application, then your ping will include the corresponding set of linked ids for that user. |
string
| fb_sig | This is the signature of the POST. Facebook uses the same signing process that your application uses to make requests to Facebook. With the exception that it truncates fb_sig_ from variable names when creating the signature.
|
PHP Example of Verification
The PHP client does all the work for you automatically as soon as you instantiate a Facebook object:
- Facebook sends the arguments via a POST.
- Facebook does not include the
fb_sigprefix when calculating the signature of the request. - Your calculated signature and the signature they POST to your script should match up.
- You can use the
fb_sig_user,fb_sig_session_keyandfb_sig_api_keyto look up which user is removing your application.
If you don't want to use the PHP client, you can do it yourself as follows:
Pseudocode Example of Verification
See notes in PHP Example of Verification for information about the POST variables.
Rails Example of Verification
- As of this writing (2/20/08), the rfacebook plugin does not seem to provide a way to handle removals (easily). Please update this section if I am mistaken.
In this example, to handle removals in your rails app we will use the post-remove URL of 'foo.yourapp.com/uninstalled'.
In your application.rb, you probably have something like:
First, add "require 'digest/md5'" to your environment.rb or the top of application.rb.
Next change your application.rb to something like:
Next, in your 'protected' section, add the following method which roughly corresponds to the PHP / pseudocode above:
I'm going to forward this snippet on to the rfacebook maintainers in case it would be of any help having it in the plugin. -SB
Also, you might have to add this entry to your config/routes.rb file:
