I am using Graph API to retrieve the access token of my facebook page..I used the code below to get a JSON respnse which contains the token for my facebook page.
AccessToken token=AccessToken.getCurrentAccessToken();
GraphRequest request = GraphRequest.newGraphPathRequest(
token,
"/me/accounts",
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
// Insert your code here
try {
//what should I do here.....
}catch (JSONException e)
{
e.printStackTrace();
}
}
});
request.executeAsync();
I got this JSON as response
{
"data": [
{
"access_token": "<access_token_is_here>",
"category": "Clothing",
"name": "<page_name_is_here>",
"id": "<id_is_here>",
"perms": [
"EDIT_PROFILE",
"CREATE_CONTENT",
"MODERATE_CONTENT",
"CREATE_ADS",
"BASIC_ADMIN"
]
}
],
"paging": {
"cursors": {
"before": "MjkzMDAyNzM0MTYwNTQ1",
"after": "MjkzMDAyNzM0MTYwNTQ1"
}
}
}
My Question is..How can I get the accessToken from this JSON response? I know that I can get the token as String..But I need it as Access Token itself so that I can use it to post status onto my facebook page….I am a beginner in this so kindly Help me…Thanks
2
Answers
Now you can also store it into sharedPref or sqlite wherever you want if you want to persist it.