Reputation: 3419
I'm working on integrating the Leaderboards API of FB with my app. And I'm kinda confused with all these permissions, user and app access tokens, and all that. I would be VERY grateful, if someone could explain to me, how to do it step by step, in a simple language. Assume that I'm really retarded and <14.
I really searched a lot to find a solution, but none of them work for me, and I'm sick of this after all day. I write in JAVA.
Okay, I did manage to get the POST and GET requests in the Graph API Explorer, it all works fine, though now I'm not sure how to get my http request in the app operational:
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("https://graph.facebook.com/me/scores");
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("score", "3000"));
try{
post.setEntity(new UrlEncodedFormEntity(pairs));
}
catch(UnsupportedEncodingException e)
{
}
try{
HttpResponse response = client.execute(post);
}
catch (IOException e1)
{
}
Another update: it had to be done with AsyncTask. And so I did, everything is almost fine, but this action requires an access token. I've searched A LOT, and I've found tones of information about access tokens, but none of which tells me, how to do it programmatically. What exactly do I have to do, to pass the access token to a HTTP request? (I've set the permissions:
authButton.setReadPermissions(Arrays.asList("user_likes", "user_status", "user_location", "user_birthday",
"user_activities", "user_games_activity"));
}
Upvotes: 3
Views: 2232
Reputation: 19995
Facebook has an entire section on working with Android. https://developers.facebook.com/android/
Consider using the official Android SDK so that you don't have to handle authentication an re-write the wheel. https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/
Once done that see how this Android sample works https://developers.facebook.com/docs/tutorials/androidsdk/3.0/games/
If you want to do it without the SDK, it is still in your best interests to understand how Facebook does authentication using their SDK so you can build your own https://developers.facebook.com/docs/tutorials/androidsdk/3.0/games/authenticate/
Access tokens are the keys allowed by a user once they have granted access to your application
See more info at https://developers.facebook.com/docs/howtos/androidsdk/3.0/login-with-facebook/
Upvotes: 3