Tuesday, August 26, 2008

Which user remove my facebook application

To remove the user who remove your application from facebook automatically.

In the settings of the application,
"Can your application be added on Facebook?" set it yes.


Scroll down, you will get a Post-Remove URL input box.



Facebook will send data to the post remove url page about the user removing the application.
The post_remove.php example from my server.


<?php

//facebook lib
require_once 'fbclient/facebook.php';

//my database config
require_once 'config/config.php';

$appapikey = 'you_app_api_key';
$appsecret = 'your_app_secret_key';

$facebook = new Facebook($appapikey, $appsecret);
$user_id = $facebook->require_login();

$user = $facebook->get_loggedin_user();

if ($user != NULL && $facebook->fb_params['uninstall'] == 1)
{
//The user has removed your app
mysql_query("DELETE FROM users WHERE userid='$user_id'") or die(mysql_error());
}

?>


Reference:
Creating Your First Application Facebook wiki
Post-Remove URL Facebook wiki

No comments: