How To Handle Expire User Access Token

Now we are discussing how to handle expire user access token. Normally we are getting expired session or does not authenticate access token exception when we are communicating with Facebook client api.
To handle this type error Facebook provide exchange access token function.
In api we just pass old user access token and get new access token.
Code

https://graph.facebook.com/oauth/access_token?client_id=$appid&client_secret=$app_secret&grant_type=fb_exchange_token&fb_exchange_token=$expiredToken

Facebook tools:

Facebook tool to get list of pages/apps with user token:
access Token

Facebook tool to to check token details:
Token Debugger

Access token in Facebook Api

There two type access token in Facebook api:
1- App access token
2- User access token/Global access token.

App access token:

Authenticating as an App allows you to obtain an access token which allows you to make request to the Facebook API on behalf of an App rather than a User.
Each app has its own access token and user access token.
Expiry of token:
1- When we set offline access enabled on Facebook app setting then we will get token for 60 days.
2- Otherwise we will get app token for only 2 hours.
Continue reading …

How To Handle Exception :PHP /Facebook Api

today we will discuss how to handle exception with Facebook graph api and php.Normally when we will create a Facebook api object, if error exist then we did not get any thing as a output, we just see a blank page.
As a point of developer view, we did not identified what problem accrued to connecting with Facebook.
In programming language we have exception class to handle all exception related issues. Facebook Api already provide his custom exception class to catch exception when error accord.

What is exception:

An exception is saving the current state of execution in a predefined place and switching the execution to a specific subroutine known as an exception handler.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
try {
		$facebook = new Facebook(array(
			  'appId'  => APP_ID,
			  'secret' => APP_SECRETCODE,
			  'cookie' => true,
		));
		return $facebook;
		} catch (FacebookApiException $e) {
			echo $e->getMessage();
		}

FacebookApiException class handle all exception related issues which will accrued when we communication with Facebook server. It will return user friendly message to identify problems.

OutPut Error Example:
Received HTTP code 407 from proxy after CONNECT

How to register user as an insights analyst role in facebook page

How to register user as an insights analyst role in facebook Page:
Step 1: First go to your facebook page dashboard.
Step2: click admin roles under edit page.

Step3: Now type the insights user id and select role from drop down list and finally click save button.

Step 4: The target insights user get the notification about he is added as insights user of page.

How to register user as an insights analyst role in facebook app

How to register user as an insights analyst role in facebook app:

Step1:

First client open his application and click ‘edit application’.

Step2:

now click role link from left panel

Step3:

Type Email id/username of insights role user.

Step4:

Now user has been added but not active. The target user will get notification on his facebook profile about he is added as an insights user to that application.

Step 5:

When you Click notification you will get below information and now click developer request.

Step 6:

Now click confirm button and notification will send to client about you have accepted request.

Role Management In Facebook Api

Facebook has its own role management. The facebook role management has different levels of access, depending on individuals’.We’re introducing the following application roles:

Administrator

– complete access to the application and all its settings

Developer

– can modify all technical settings and access Insights but cannot reset secret key, delete application, or add additional users

Tester

– can test the application in sandbox mode but cannot modify the application

Insights User

– can access Insights but cannot modify the application

Online tool of Facebook api webservice and fql

Now i am discussing how to check online Facebook api webservice and fql.
Facebook provide online tool to check api method.
http://developers.facebook.com/tools/explorer/

This tool has many features like:

api access
1- Access api through graph as well as FQL.
2- Set access permissions of user.
3- Get online access token for web service.
4- Access all method of graph in single umbrella.

How to create pages on facebook and get page information

Now days is social media era,so social media is important part of marketing and get useful audience from social media.Here i am discussing how to create page for website on Facebook and get data from graph api.

step1: First we will create page under profile.
step 2: Setting page admin under ‘manage_permission menu’.

manage_permissions

step3: You can add many admin user for this particular user.

add_admin

step 4: setting pwrmision to read page information.

AUTH_URL.”?client_id=”.$app_id . “&redirect_uri=” . urlencode($canvas_page).”&response_type=token&scope=manage_pages;
step 5: Results:

result contains following information:
1- name: name of page/application
2- access_token: To access page/app information.
3- category: ttells its app or page.
4-perms: permision of app/pages.