I spend a lot of time fingering out how to add “Custom Tab” in face-book fan page.
In fact this is very easy through PhpFacebook API.
You need to have “manage_pages” permission during user authorization.
This code will allow you to get control of all fab pages. This code is good for someone who is willing to add his tab/app to fab page. This is not good for normal user.
$logoutUrl = $facebook->getLogoutUrl();
$params = array(
'scope' => 'offline_access, email, publish_stream, manage_pages',
'redirect_uri' => 'https://apps.facebook.com/your-app-name/'
);
If you logged in successfully this code will show you all fan pages with Id and names etc.
$pageIds=$facebook->api('/me/accounts');
print_r($pageIds); // this will show you array data. This is key part and show you access_token which is very imp.
[0] => Array
(
[name] => My App Tester
[access_token] => AAAD3pm1y4sQBADkZA4mT1UNFzUyQZBw9g1aH2CCriZCAHyqmP6rvHurcZC0qShvPFhPB0R4CWP7TMxVzHp2ktepcrM1XZBheZCoZD
[category] => Computers/internet
[id] => 56789349409295678
[perms] => Array
(
[0] => ADMINISTER
[1] => EDIT_PROFILE
[2] => CREATE_CONTENT
[3] => MODERATE_CONTENT
[4] => CREATE_ADS
[5] => BASIC_ADMIN
)
)
$pageAccessToken=$pageIds["data"][1]["access_token"];
Now it is time to post you can use Ajax or any way you like to post. PAGE_ID is your fan page ID/56789349409295678.
$facebook->api("/PAGE_ID/tabs","post", array("access_token" => $pageAccessToken, "app_id" => $appId));
Now you can store PAGE_ID in database and when you will run this code then one tab will be added in your fan page.
Now your user can access whatever you add in your app.
use this code in your app page to correlate custom app for different user since you already have PAGE_ID stored in db
";
print_r(parse_signed_request($signed_request, $secret));
?>
Using this method you can create multiuser fab page tab application and make some money by adding extra features!
this doesn’t work. the generated access token is not a page token. its only a user token. also,this code is very old and some of the stuff do not work with the new facebook api.