Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change tab name facebook page

Tags:

facebook

Is there a way to change the tab name of facebook page by
facebook graph API using PHP SDK. I think it is constant during
setup of facebook application.

after setting tab name of an application can I change tab name of facebook
page later by graph API.

like image 968
msaif Avatar asked Oct 21 '11 06:10

msaif


2 Answers

Yes you can do this using the graph api.

First you have to get an access token for the page, to do this you will need to ask for the manage_pages permission.

Once you've initialized the PHP SDK to get the the page access token you make a call to...

$facebook->api('/THE_PAGE_ID?fields=access_token');

This returns an array like below

{
  "access_token": "THE_PAGE_ACCESS_TOKEN", 
  "id": "THE_PAGE_ID", 
  "type": "page"
}

Before you use this token you may want to save the current users access token so you can set set it back again once you've finished doing the page stuff.

$users_access_token = $facebook->getAccessToken(); 

To then make the SDK use the page access token for the next call do

$facebook->setAccessToken('THE_PAGE_ACCESS_TOKEN');

Now we're ready to change the tab name by making a POST to /THE_PAGE_ID/tabs/TAB_ID with an array containing the new custom name

$this->api('/THE_PAGE_ID/tabs/TAB_ID', 'POST', array(
    'custom_name' => 'THE_NEW_TAB_NAME'
));

TAB_ID should be the tab apps id prepended by app_

That should be it, don't forget to set the access token back to the users token before you try do anything non tab related

$facebook->setAccessToken($users_access_token);

It might be worth noting that you can use exactly the same process to change the tab position and set the default landing tab, you just need to add a couple of extra bits to the POST array, 'position' and 'is_non_connection_landing_tab'

$this->api('/THE_PAGE_ID/tabs/TAB_ID', 'POST', array(
    'custom_name' => 'THE_NEW_TAB_NAME',
    'position' => 1,
    'is_non_connection_landing_tab' => true
));
like image 141
Jont Avatar answered Sep 30 '22 18:09

Jont


Have a look here http://developers.facebook.com/docs/reference/api/page/ scroll down to Tabs. Graph api provides Read, Create, Update, Delete functionality.

like image 26
Alexandros B Avatar answered Sep 30 '22 17:09

Alexandros B