Understanding Facebook Graph API. how to request for information
NOTICE! This post is too old, to implement Facebook SDK into your AdobeAIR app, read here.
Graph API is a very powerful restful API provided by Facebook which enables you to retrieve many different information from your users Facebook accounts based on the permissions that they Grant you. If I want to put it in very simple words, the graph API works as follow. you can call the graph from your Air app and tell the graph what information you need. if the information you are requesting is public on Facebook, you won’t need any access token. but if you are asking for personal information, you need to have logged in your users first and have a valid access token.
Our Facebook ANE gives you full access to the Graph API (you can set the graph version to connect to yourself. the default version is v2.3 which is the latest graph version when building this extension. but you are not limited to that and you can change that yourself.)
in this post, I will show you how to call on the Graph and how to retrieve the information from Facebook. but if you need to learn more about Graph, you should read the Facebook official docs here https://developers.facebook.com/docs/graph-api/reference
import com.myflashlab.air.extensions.facebook.FB;
import com.myflashlab.air.extensions.facebook.FBEvent;
// when working with the FB ANE, you always need to initialize it with your fb app ID first
FB.getInstance("00000000000000"); // you need to call this only once when your app starts.
// add listeners to get the response from the Graph API
FB.graph.addEventListener(FBEvent.GRAPH_RESPONSE, onGraphResponse);
FB.graph.addEventListener(FBEvent.GRAPH_RESPONSE_ERROR, onGraphError);
// then request for information. if you are logged in, the access token will be sent automatically.
FB.graph.call("https://graph.facebook.com/v2.9/me", URLRequestMethod.GET, new URLVariables("fields=name,email,picture&metadata=0"));
function onGraphResponse(event:FBEvent):void
{
FB.graph.removeEventListener(FBEvent.GRAPH_RESPONSE, onGraphResponse);
FB.graph.removeEventListener(FBEvent.GRAPH_RESPONSE_ERROR, onGraphError);
trace(event.graphRequest);
trace((event.param);
}
function onGraphError(event:FBEvent):void
{
FB.graph.removeEventListener(FBEvent.GRAPH_RESPONSE, onGraphResponse);
FB.graph.removeEventListener(FBEvent.GRAPH_RESPONSE_ERROR, onGraphError);
trace("ERROR!");
trace(event.graphRequest);
trace(event.param);
}
Adobe Air + Facebook SDK integration part 7
Understanding Facebook Graph API. how to request for information
Graph API is a very powerful restful API provided by Facebook which enables you to retrieve many different information from your users Facebook accounts based on the permissions that they Grant you. If I want to put it in very simple words, the graph API works as follow. you can call the graph from your Air app and tell the graph what information you need. if the information you are requesting is public on Facebook, you won’t need any access token. but if you are asking for personal information, you need to have logged in your users first and have a valid access token.
Our Facebook ANE gives you full access to the Graph API (you can set the graph version to connect to yourself. the default version is v2.3 which is the latest graph version when building this extension. but you are not limited to that and you can change that yourself.)
in this post, I will show you how to call on the Graph and how to retrieve the information from Facebook. but if you need to learn more about Graph, you should read the Facebook official docs here https://developers.facebook.com/docs/graph-api/reference
Share this:
Related