Android Facebook Album cover photo - android

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}

Related

Android facebook upload photo on a feed page

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

Test publish permissions for Facebook app

I want to test the publish permissions for my facebook app, however when using the graph api(s) to either like or comment, I get an error from the facebook server.
The code being used to post a like is as below:
Bundle params = new Bundle();
params.putString("url", "http://www.imdb.com/title/tt2015381/");
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/" + facebookObjectId + "/likes",
params,
HttpMethod.POST,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
Log.i(TAG, "FACEBOOK GRAPH RESPONSE FOR POSTING LIKE: " + response);
}
}
).executeAsync();
The corresponding error that is being generated is:
FACEBOOK GRAPH RESPONSE FOR POSTING LIKE: {Response: responseCode: 403, graphObject: null, error: {HttpStatus: 403, errorCode: 200, errorType: OAuthException, errorMessage: (#200) App does not have permission to make this call}}
essentially suggesting that App does not have permission to make this call
To post custom like:
Bundle params = new Bundle();
params.putString("object", linkURL);
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/" + Profile.getCurrentProfile().getId() + "/og.likes",
params,
HttpMethod.POST,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
Log.i(TAG, "FACEBOOK GRAPH RESPONSE FOR POSTING LIKE: " + response);
}
}
).executeAsync();
To delete custom like:
Bundle params = new Bundle();
params.putString("object", linkURL);
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/" + likeActionInstanceId,
params,
HttpMethod.DELETE,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
Log.i(TAG, "FACEBOOK GRAPH RESPONSE FOR DELETING LIKE: " + response);
}
}
).executeAsync();
Here the likeActionInstanceId is the id received after submitting the like successfully.
NOTE: Comments can't be added as of now from your own app. Comment Mirroring is in beta phase at Facebook.

get friend's profile picture url or profile picture using graph api v2.3 in android

new GraphRequest(AccessToken.getCurrentAccessToken(),
"/"+userId+"/picture",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */ Log.e("new Response","----"+response);
}
}
).executeAsync();
}
I am getting response like below.
Response:
responseCode: 200, graphObject:
{"FACEBOOK_NON_JSON_RESULT":"����\u0000\u0010JFIF\u0000\u0001\u0002\u0000\u0000\u0001\u0000\u0001\u0000\u0000��\u0000�Photoshop"},
error: null}
Instead of creating executeGraphPathRequestAsync request, create simple GET request.
graph.facebook.com/YOUR_USER_ID/picture
Check below link to get image from remote url:
How to load an ImageView by URL in Android?

Android Facebook SDK getRequestForPagedResults always null

I´m trying to crawl through every Picture a Page has uploaded to Facebook with Pagination. Although, the response of Facebook has got Pagination Details both in the response and in the Graph Explorer Tool, the method response.getRequestForPagedResults alwways returns null.
Does anyone know why?
Here is my code
GraphRequest request = GraphRequest.newGraphPathRequest(accessToken, "/" + timelinePhotos,
new GraphRequest.Callback() {
#Override
public void onCompleted(GraphResponse response) {
GraphRequest nextRequest = response.getRequestForPagedResults(GraphResponse.PagingDirection.NEXT);
Log.e("HALLO", response.toString());
JSONObject obj = response.getJSONObject();
JSONArray data = null;
if(nextRequest!=null){
nextRequest.setCallback(this);
nextRequest.executeAsync();
}else{
Log.e("HI", "ICHBINFEDDIIICH");
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "photos{likes.limit(0).summary(true)}");
request.setParameters(parameters);
request.executeAsync();
Here is the response I get from facebook
01-04 04:42:03.564: E/HALLO(983): {Response: responseCode: 200,
graphObject: {"id":"853505791349630","photos":{"data":
[{"id":"1187285891304950","likes":{"summary":
{"can_like":true,"total_count":678,"has_liked":false},"data":[]}},
{"id":"1185272354839637","likes":{"summary":
{"can_like":true,"total_count":2245,"has_liked":false},"data":[]}},
{"id":"1184689078231298","likes":{"summary"
:{"can_like":true,"total_count":3242,"has_liked":false},"data":[]}}, ....lots of more IDS
"paging":{"cursors": {"after":"MTE2NzU2MDEyOTk0NDE5MwZDZD","before":"MTE4NzI4NTg5MTMwNDk1MAZDZD"},"ne
xt":"https:\/\/graph.facebook.com\/v2.5\/853505791349630\/photos?
access_token=XXX
jKzSgbusvQKMXtXmIsgl01T
vTEPQBZCp3XhM8ieGCYclmmuc7FzVDyl8jcJTW&
fields=likes.limit%280%29.summary%28true%
29&limit=25&after=MTE2NzU2MDEyOTk0NDE5MwZDZD"}}}, error: null}
So, as you can see, there clearly is a Paging-Information, so why is my nextRequest alway null?

facebook realtitme update in android returns null

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}

Categories

Resources