On android I'm using Facebook SDK 4.0. I want to get all photos of a user logged in via Facebook login.
I have this URL
https://graph.facebook.com/FACEBOOK_ID/albums?access_token=TOKEN
How do I parse and generate images to be viewed in a ListView ?
set Bundle for extra parameters like crate a bundle for required parameters ex:
Bundle parameters = new Bundle();
parameters.putString("fields", "id, picture");
Then set it to GraphRequest.
you have to used below code to get all photos of user.
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{user-id}/photos",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
Related
Bundle params = new Bundle();
params.put("file_url","video_url")
params.put("title","post video")
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{page-id}/videos",
params,
HttpMethod.POST,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
In that particular video posting graph api there is one parameter as per documentation please have a look.
There is one param referenced_sticker_id which means "Sticker id of the sticker in the post"
but how can i use this parm by which i can share my sticker with video i try it by using image url but it doesn't work.It needs Numeric string or integer value foe sticker.
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 trying to get the posts from a page including all the pics related to the post.
I am able to get one picture from the post using object_id, but I need the other photos as well.
object_id returns only one Id which is the first photo's ID.
Please help.
GraphRequest greq =
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{page-id}/posts",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
JSONArray data = null;
}
}
);
Bundle params = new Bundle();
params.putBoolean("redirect",false);
params.putString("fields", "object_id");
greq.setParameters(params);
greq.executeAsync();
The data should be in the attachments field. In the subattachments sub-field specifically.
You should test this in the Graph API Explorer to see the API response and update your Android implementation based on that.
here is the facebook sample
Bundle params = new Bundle();
params.putString("source", "{image-data}");
/* make the API call */
new Request(
session,
"/me/photos",
params,
HttpMethod.POST,
new Request.Callback() {
public void onCompleted(Response response) {
/* handle the result */
}
}
).executeAsync();
what is {image-data}
I tried use byte[].toString, file.toString, path of file. not work.
so how to upload photo with this api?
facebook doc is wrong.
change
params.putString("source", "{image-data}");
to
params.putByteArray("source", "{image-data}");
If you want to post a photo, use one of the Request.newUploadPhotoRequest methods, it will set everything up for you.
See https://developers.facebook.com/docs/reference/android/current/class/Request/#newUploadPhotoRequest
I'm using Facebook android SDK to execute a graph call to fetch all my friends. I'm trying to use the 'If-None-Match' request header but I can't find a way to add headers to the request. I'm managing to get the eTag header from the response but without an option to use it. Here is my code:
Bundle bundle = new Bundle();
bundle.putString("fields", "id,installed,name,picture");
new com.facebook.Request(
ParseFacebookUtils.getSession(),
"/me/friends",
bundle,
HttpMethod.GET,
new Request.Callback() {
/**
*
* #param response
*/
#Override
public void onCompleted(com.facebook.Response response) {
// Getting the eTag using response.getHttpConnection.getHeader("eTag");
}
}
).executeAsync();