How to show facebook photo gallery in my app? - android

Is there a way for me to pull Facebook photo album and display it in my app ? I mean with the UI Interface to select the photo, not only to retrieve the url of the photos (via graph api I guess) and later build our-self the ui interface (ie: the gallery) to let the user select the photo.
Is their something like this in the facebook SDK for android/ios ?

You can use to Graph API in Facebook SDK
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{album-id}/photos",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
Facebook Graph API alum photos
Add the compile dependency with the latest version of the Facebook SDK in the build.gradle file:
dependencies {
compile 'com.facebook.android:facebook-android-sdk:4.+'
}
facebook getting started
Add Facebook App ID
Then add your Facebook App ID to your project's strings file and update your Android manifest:
Open your strings.xml file. Example path: /app/src/main/res/values/strings.xml.
Add a new string with the name facebook_app_id and value as your Facebook App ID
Open AndroidManifest.xml
Add a uses-permission element to the manifest:

Related

How to add Facebook App's accessToken to GraphRequest.newGraphPathRequest method? [duplicate]

This question already has answers here:
Accessing Facebook Graph API without login
(2 answers)
Closed 5 years ago.
I copied the code below from Facebook Graph Api console. However, Android Studio doesn't recognize accessToken.
I have alread created a Facebook App and I got its acesstoken. But I don't know where to add it in the code. If I just copy and paste. It shows this error
If I use AccessToken.getCurrentAccessToken() method, it will show this error:
errorMessage: An access token is required to request this resource
Here is my code:
GraphRequest request = GraphRequest.newGraphPathRequest(
accessToken,
"/ibm/events",
new GraphRequest.Callback() {
#Override
public void onCompleted(GraphResponse response) {
Log.d(TAG, "onCompleted: " + response.toString());
}});
Bundle parameters = new Bundle();
parameters.putString("fields", "name,cover,start_time,end_time,place,description");
parameters.putString("limit", "3");
request.setParameters(parameters);
request.executeAsync();
}
Firstly :
Make a Facebook app with these simple steps I have written below:
Go to Developer tab and click on it.
Then go to Website Option.
Enter the app name which you have want.
Click on Create Facebook App.
After this you have to choose category, you can choose App for Pages.
Your AppId and Appkey is created automatically. The AppSecretKey is obfuscated. You can click on the show button to see your AppId and AppSecurityKey.
Then Check this link to generate access token
1.Copy and Paste Your App ID & Your App Secret into the generator below. You can get your App ID & your App Secret by clicking on the Apps main menu option and then choosing your newely created App.
Next click the Tools Menu and then choose Graph API Exploer.
page1
On this page you will click the Graph API Explorer select option.
Then choose your Application from the list. In this example we'll use Custom Feed.
Now you click on the Get Access Token. This will show a Select Permissions popup as you will see next.
Next Click on the Extended Permissions menu option and click the checkbox read_stream and click Get Access Token. DO NOT CHECK read_stream if you are using our plugin to display a Page on facebook.
6.Then click the Okay button to continue.
Fetch Event IN Android : You have to download Android facebook sdk and put you access token there getCurrentAccessToken() in this method.
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{event-id}",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
Event Details

How to get user's friends profile photo (avatar) from Facebook

I'm working on an Android version of an app that uses Facebook for authorization and for retrieving user's friend list.
As of SDK v.2.0, it became pretty hard to get list of friends that hadn't installed your app, but I made it work and now I need to get links to friends profile pictures (avatars). But Facebook does not want to return normal IDs for friends that haven't installed the app. For example, if a friend installed an app then FB returns its ID as digits, something like this 651651616851, and if not then FB returns string of chars like "glkjrgbdjrbgjdrbhgjhLFKBfEFbFkjgnrg".
If I use digit-like ID to retrieve photo, it works, but if I try to use charlike ID, FB returns an 803 error.My question is how do I get normal IDs or how to get friends profile pictures?
This is the API call to get the pictures of friends, you can specify a (minimum) width and height:
/me/friends?fields=picture.width(400).height(400)
Please follow the link of facebook sdk about the Track Current Profile.
FacebookSdk.sdkInitialize(this.getApplicationContext());
callbackManager = CallbackManager.Factory.create();
ProfileTracker profileTracker = new ProfileTracker() {
#Override
protected void onCurrentProfileChanged(
Profile oldProfile,
Profile currentProfile) {
// App code
Uri uri = currentProfile.getProfilePictureUri(200,200);
}
};
Now From Uri you can download the profile picture of user current profile.

Share to facebook from background - Android - Facebook SDK v4.x

I want to be able to seamlessly publish to a users Facebook feed from the background in my Android application. The user is fully aware of the content they are publishing, but the post will be made after a relatively long upload process, so the user should not be made to wait. I am using the Android Facebook SDK v4.1.2.
I see that I need to request the "publish_actions" permission from the user beforehand:
https://developers.facebook.com/docs/facebook-login/permissions/v2.3#reference-publish_actions
I can use the LoginManager to get the access token:
https://developers.facebook.com/docs/facebook-login/android/v2.3#access_profile
I am then not sure how to share a link to the users feed without using the ShareDialog:
https://developers.facebook.com/docs/sharing/android
This SO question suggests using the Request object for v3.x, which is equivalent to the GraphRequest object for v4.x:
https://developers.facebook.com/docs/reference/android/current/class/GraphRequest/
but I am not sure how to build the correct GraphRequest. I assume I need to publish a message to "/me/feed":
https://developers.facebook.com/docs/graph-api/reference/v2.3/user/feed
Can anyone tell me how to do this?
In writing the question I found my own solution from trawling the docs and examples. I need to publish a message to "/me/feed":
https://developers.facebook.com/docs/graph-api/reference/v2.3/user/feed
Bundle params = new Bundle();
params.putString("link", link);
GraphRequest request = new GraphRequest(AccessToken.getCurrentAccessToken(),
"/me/feed", params, HttpMethod.POST,
new GraphRequest.Callback() {
#Override
public void onCompleted(GraphResponse graphResponse) {
}
});
request.executeAndWait();
After obtaining the "publish_actions" permission.
You should use the ShareApi class if you don't want to build the params bundle yourself.
Build a ShareLinkContent as you normally would:
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse("https://your.url.com"))
.build();
Then call ShareApi:
ShareApi.share(content, new FacebookCallback<Sharer.Result>() {...});

facebook How to get all photo of logged in User?

I create app to Facebook with facebook-android-sdk:4.1.0
How to get all photo of logged in User?
I need to load user all photo
I use this code
I read this
I have to use Graph API
/* make the API call */
new Request(
session,
"/{photo-id}",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
/* handle the result */
}
}
).executeAsync();
please help
please explain
You can get everyone's Facebook profile picture using below.
You just call http://graph.facebook.com/USERNAME_OR_USERID/picture?type=large. This URL redirects you to image URL.
extention onto my answer:
how do I get the entire album?
You need https://graph.facebook.com/[uid]/albums?access_token=[AUTH_TOKEN] to get JSON array of all the albums of a user.
You will get three important things from here id - album id, name - album name, and type - album type.
What permissions do I need?
The permission required is user_photos see here
What is the best way to get ALL profile pictures from a given user?
Profile Pictures are under "Profile Pictures" album. To get to profile album, you need to look into albums array (as mentioned previously), iterate through the JSON result-set, until you get an album with name = Profile Pictures and type = profile. Get id of this object. This is the profile pictures album.
Now you can access it similar to you access any other album. That is, https://graph.facebook.com/[ALBUM_ID]/photos?access_token=[AUTH_TOKEN] this will list all the profile pictures of the user ever uploaded.
Hope this helps.
refer: http://developers.facebook.com/docs/reference/api/

how Facebook taggable_friends permission work in facebook sdk 2.2

i am trying to understand new taggable_friends permission added in facebook sdk works?
i am getting all friends list in previous Facebook sdk ,
but in new Facebook sdk its not allowed only those friends will display who are using this app,
is there any way to get all friends list ?
what taggable_friends do ,can i get all list by using this permission?
/{user-id}/taggable_friends
new Request(
session,
"/me/taggable_friends",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
/* handle the result */
}
}
).executeAsync();

Categories

Resources