I would like to get realtime_update when user's friendlist changes and am trying to subscribe to friends object .I have the code below where I added params.putString("access_token", "12|wewee"); because I used to get {This method must be called with an app access_token.}, isFromCache:false} .Now I get the response as displayed below.I would like to get realtime subscription .How do I make it work? I really appreciate any help.Thanks in Advance.
code:
Bundle params = new Bundle();
params.putString("object", "user");
params.putString("access_token", "12|wewee");
params.putString("callback_url", "http://example.com/callback/update.php");
params.putString("fields", "friends");
params.putString("verify_token", "1234");
/* make the API call */
new Request(
session,
"/12345/subscriptions",
params,
HttpMethod.POST,
new Request.Callback() {
public void onCompleted(Response response) {
/* handle the result */
}
}
).executeAsync();
Note: session =fb.getsession();
added param to get app_access_tokem:
params.putString("access_token", "12|wewee");
and I get this response :
{Response: responseCode: 200, graphObject: GraphObject{graphObjectClass=GraphObject, state={"FACEBOOK_NON_JSON_RESULT":null}}, error: null, isFromCache:false}
Related
I am trying to fetch Cover Photo of an album using Graph API.
Here is my code:
Bundle params = new Bundle();
params.putString("type", "thumbnail");
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/" + albumID + "/picture",
params,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
Log.v("TAG", "Facebook Photos response: " + response);
}
}
).executeAsync();
Using above code, I am getting below response:
{Response: responseCode: 200, graphObject: {"FACEBOOK_NON_JSON_RESULT":"����\u0000\u0010JFIF\u0000\u0001\u0002\u0000\u0000\u0001\u0000\u0001\u0000\u0000��\u0000�Photoshop"}, error: null}
Can anyone help me what is wrong with my request and how I can get a cover photo of an album?
Thanks in advance.
After googling, I found a solution and its working fine for me.
I have changed Bundle parameters as below:
Bundle params = new Bundle();
params.putString("type", "thumbnail");
params.putBoolean("redirect", false);
Rest of code as it.
After changing, I am getting proper response same as I get in Graph API browser:
{Response: responseCode: 200, graphObject: {"data":{"is_silhouette":false,"url":"https:\/\/scontent.xx.fbcdn.net\/v\/t1.0-0\/s180x540\/13782019_1735895746671060_1058868038400371031_n.jpg?_nc_cat=0&oh=506c19df47791a4b7fcfc362eeed0676&oe=5B92AA68"}}, error: null}
Hi guys I am trying to upload a photo to a page on Facebook. This is the page i am trying to post the photo https://www.facebook.com/manegedagen/.
I have been using the following code :
public static void postImageOnWall(Bitmap pBitmap) {
Bundle bundle =new Bundle();
bundle.putString("method", "photos.upload");
bundle.putString("picture","http://www.demos.com/LangGuage/medal_1.png");
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/2091172661108128/feed",
null,
HttpMethod.POST,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
Log.e("", "");
}
}
).executeAsync();
}
But i am getting an error message: OAuthException: errorMessage: Invalid parameters. I would really appreciate if i can get any guide or help.
Try with parameters not as null
see the selected answer from this reference:
https://stackoverflow.com/a/29770773/6011938
I am using Facebook SDK 4.x, and i need to get friend list with name but i can't get it,
i have also implemented this graph API
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me/friend",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
and this is my reponse
response {Response: responseCode: 200, graphObject: {"summary":{"total_count":3},"data":[]}, error: null}
I am not getting friend list with name, if you have any idea than plz give me.
Thanks in Advance.
I got solutions for using this
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me/taggable_friends",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
Log.e("getFriendsDat",""+ response);
}
}
).executeAsync();
You will get friend list with name and detail.
you have to add user_friends permission and need to submit your app for review.
First of all, it´s /me/friends, not /me/friend. That being said, you can only get access to friends who authorized your App too, with the user_friends permission. The response means that you have 3 friends, but none of them authorized your App with user_friends.
More information: Get ALL User Friends Using Facebook Graph API - Android
I need to get the age_range from facebook.
When i use /me?fields=age_range in my GraphRequest.newGraphPathRequest i get an error.
The error is that graphObject returns null. I've tried using /me and it works i get the correct user data though when i use /me?fields=age_range i get this error.
Testing﹕ {Response: responseCode: 400, graphObject: null, error: {HttpStatus: 400, errorCode: 2500, errorType: OAuthException, errorMessage: An active access token must be used to query information about the current user.}}
This is the code i've been trying to fix.
GraphRequest request = GraphRequest.newGraphPathRequest(accessToken,
"/me?fields=age_range",
new GraphRequest.Callback() {
#Override
public void onCompleted(GraphResponse graphResponse) {
Log.v("Testing", graphResponse.toString());
}
});
request.executeAsync();
You should not put "/me?fields=age_range" as the path in your GraphRequest.
Instead, only use "/me" as the path, and then create a new Bundle, and put "fields" as the key, and "age_range" as a string value, and set the new bundle as the parameters on the GraphRequest.
GraphRequest request = ...
...
Bundle params = new Bundle();
params.putString("fields", "age_range");
request.setParameters(params);
request.executeAsync();
...
From within my Android application, i am trying to implement a simple "Like Button" functionality.
We have already executed Facebook log in from the same app.
We have also created an Open Graph Like action & a Link object as well on our App's Dashboard.
This is the code that we are using to publish the like.
public static void likeFacebookPage(Context context,String pageUrl)
{
Bundle params = new Bundle();
params.putString("object",pageUrl);
Request request = new Request(
Session.getActiveSession(),
"me/og.likes",
params,
HttpMethod.POST
);
Response response = request.executeAndWait();
// handle the response
}
In the pageUrl parameter, we have:
http://www.facebook.com/<object_id>
"object_id" is the Id of the Link Object that we have created in Open Graph.
After executing the above method, the response object received as follows:
{Response: responseCode: 200, graphObject: null, error: {HttpStatus: -1, errorCode: -1, errorType: null, errorMessage: null}, isFromCache:false}
But the Like count is not getting updated, leading us to believe that this process is not working.
We have also included the permissions "publish_actions" & "user_likes" in our code as well as on the App Dashboard.
Kindly help us with configuring this functionality.
Thanks in advance.
As described here https://developers.facebook.com/docs/reference/api/publishing/ you publish a like to an object like so with the publish_actions and publish_stream permissions:
Bundle postParams = new Bundle();
Request request = new Request(Session.getActiveSession(),
FB_OBJECT_ID+"/likes", postParams, HttpMethod.POST, new Callback() {
#Override
public void onCompleted(Response response) {
}
});
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
Where your FB_OBJECT_ID is simply the ID of the object. I.e if you want to like a photo, FB_OBJECT_ID would be the pid. For an album, FB_OBJECT_ID would be the aid.