Facebook URL mentioned below return empty data but there is album images in Facebook, i am using new Facebook SDK 3.5.2. anyone have suggestion please help me to come out of this issue.
Thanks on advance
"https://graph.facebook.com/ID/albums?access_token=Token";
I was having the same problem. Read this. Some users dont allow access to their albums and photos through apps. You will have to code accordingly.
Session.NewPermissionsRequest np = new Session.NewPermissionsRequest(this, "friends_photos");
Session.getActiveSession().requestNewReadPermissions(np);
Request rq = new Request(Session.getActiveSession(), userID + "/albums", null, HttpMethod.GET, new Request.Callback() {
#Override
public void onCompleted(Response response) {
}
});
rq.executeAsync();
}
Here is what it should look like. just change userID to the user whose albums you want to retrieve with response being the data that is returned.
I got result by adding below this permissions but i need album list now i get only cover photo and profile picture.
if(session != null && !session.isOpened()){
OpenRequest openRequest = new OpenRequest(this).setCallback(statusCallback);
if (openRequest != null) {
openRequest.setDefaultAudience(SessionDefaultAudience.EVERYONE);
openRequest.setPermissions(Arrays.asList("friends_hometown","user_photos","friends_photos"));
openRequest.setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK);
session.openForRead(openRequest);
}
}
Related
I need the key which specifies a friends that can be taged in a post (facebook)
if (session.isOpened()) {
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(this, "publish_actions");
session.requestNewPublishPermissions(newPermissionsRequest);
}
Request request = Request.newStatusUpdateRequest(Session.getActiveSession(), "Join me", new Request.Callback() {
#Override
public void onCompleted(Response response) {
showPublishResult("Result", response.getGraphObject(), response.getError());
}
});
Bundle params = request.getParameters();
params.putString("message", "hello test 10");
params.putStringArray("tags", new String[]{id});
request.setParameters(params);
request.executeAsync();
The above code only posts on facebook wall without taging the friend whose 'ID' is passed.
Is there any solution for taging my friend in the post on the facebook wall
Please suggest if anything wrong in the above code
I have tried "tags", "with_tag","tag","to" but nothing seems working.
This is the link from were I have read all the doc facebook dev doc
can any one help me with this
You need to specify a place in order to use tags. From: https://developers.facebook.com/docs/graph-api/reference/v2.0/user/feed
tags: Comma-separated list of user IDs of people tagged in this post. You cannot specify this field without also specifying a place.
In an Android App I have the following code:
private void requestDataFromFb() {
Callback callback = new Callback() {
#Override
public void onCompleted(Response response) {
AppLog.Log(TAG, "Facebook Response ::" + response + "");
Utility.closeprocess(Login.this);
loadImage(response);
}
};
String graphPath = "me";
Bundle bundle = new Bundle();
bundle.putString("fields",
"id,picture.height(250),gender,first_name,last_name,age_range");
Request mRequest = new Request(Session.getActiveSession(), graphPath,
bundle, HttpMethod.GET, callback);
RequestAsyncTask task = Request.executeBatchAsync(mRequest);
if (task == null) {
AppLog.Log(TAG, "task is null");
} else {
AppLog.Log(TAG, task.getStatus() + "");
}
}
It's been working fine and I am getting the paths to the user's profile picture. However, after some time the paths don't work anymore. One cannot see the picture of the first users. When I enter the URL in my browser I get:
An error occurred while processing your request.
Reference #50.3d1431b5.1424197137.a584ec67
And when using the Graph API Explorer of Facebook I get a different URL for the picture.
I do not know if that has something to do with the fact that the user has changed their profile picture or something else, and how I could solve this issue.
Any advise or guidance would be greatly appreciated
I am creating an application. I want to access the friends list form Facebook in my app, but i am unable to access the Facebook friends list in my app. All others thinks are accessible, only friend list is not accessible. I have an old app id in which i access all the friends but in my new app id i am unable to access the friend list. In my app, I mention the following permissions:
1. Public_Profiles
2. basic_info
3. user_photos
4. user friends
5. read_friendslist
if any others permissions are needed then please let me know.
You new app is using API v2.0 and in API v2.0 you can not get all friends. /me/friends will only return friends that are also using the app.
There are some new APIs added in v2.0 that you may be able to use: taggable_friends, invitable_friends and social context.
I am getting friends list in two ways:
`Session activeSession = Session.getActiveSession();
if (activeSession.getState().isOpened()) {
Request friendRequest = Request.newMyFriendsRequest(activeSession,
new GraphUserListCallback() {
#Override
public void onCompleted(List<GraphUser> users,
Response response) {
UsefullData.Log("Response : " + response.toString());
UsefullData.Log("Friends list" + users);
//setUserFriendsList(users);
}
});
Bundle params = new Bundle();
params.putString("fields", "id, name, picture");
friendRequest.setParameters(params);
friendRequest.executeAsync();
}`
Request friendRequest = new Request(
activeSession,
"/me/friends",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
UsefullData.Log("Friends Response : " + response.toString());
//setUserFriendsList(response);
}
}
);friendRequest.executeAsync();
Note: set custome permission "user_friends" in your session.
both codes are working at my end. I hope it will help for you.
I want to get a list of a users albums names and ids. You need to add the permission users_photos for this.
I created a method called fetchAlbums, and in it I am requesting additional permissions. But by the time the permissions dialog pops up, the rest of the method has already executed (without the needed permissions!).
Whats the best way to do this, add the permissions in the onCreate of the Activity?
private void fetchAlbumsFromFB() {
Session session = Session.getActiveSession();
// make a new async request
Bundle params = new Bundle();
params.putString("fields", "id, name");
new Request(
session,
"/me/albums",
params,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
// use response id to upload photo to that album
//errText.setText("New Album created response: " + response.toString());
//need to get the newly created album ID.
try{
JSONObject graphResponse =response.getGraphObject().getInnerJSONObject();
Toast.makeText(getApplicationContext(), "Albums " + graphResponse.toString(), Toast.LENGTH_LONG).show();
}
catch (Exception e) {
e.printStackTrace();
albID = null;
}
}
}
).executeAsync();
}
It's better to ask for user_photos permission at the starting point, when the user is authenticating the app the first time.
Since it's not an extended/publish permission, it will be asked along with the basic permissions and user wont bother too; else user will see the permission dialogs again and again that could frustrate him.
I guess, in that case this problem will be solved too.
I am using the Facebook Android SDK. Is there an easy way to get a user's friends who have downloaded the app? For example, the app Draw Something implements this. I can't seem to find any information on this subject
I would guess that if it was possible, some extra information would be needed in the httppost to access this information.
* Note: since 3.14 version, me/friends will only return friends that also use the app, so below implementation is deprecated. See the new "Invitable Friends" or "Taggable Friends" APIs for alternatives.
Using the new Facebook SDK for Android (3.0) is very easy to get your user's friend list.
Following is the code:
private void requestFacebookFriends(Session session) {
Request.executeMyFriendsRequestAsync(session,
new Request.GraphUserListCallback() {
#Override
public void onCompleted(List<GraphUser> users,
Response response) {
// TODO: your code for friends here!
}
});
}
Nevertheless, in order to get the user's friends who are using your Facebook app is a little bit complicated (due to Facebook API documentation). But yes, it is possible.
First of all, create your request:
private Request createRequest(Session session) {
Request request = Request.newGraphPathRequest(session, "me/friends", null);
Set<String> fields = new HashSet<String>();
String[] requiredFields = new String[] { "id", "name", "picture",
"installed" };
fields.addAll(Arrays.asList(requiredFields));
Bundle parameters = request.getParameters();
parameters.putString("fields", TextUtils.join(",", fields));
request.setParameters(parameters);
return request;
}
Note that you need to insert the field "installed" in your request. I'm requesting the user picture path with the same request. Check your possibilities here.
Next, you can use above code to create your request and then get your friends:
private void requestMyAppFacebookFriends(Session session) {
Request friendsRequest = createRequest(session);
friendsRequest.setCallback(new Request.Callback() {
#Override
public void onCompleted(Response response) {
List<GraphUser> friends = getResults(response);
// TODO: your code here
}
});
friendsRequest.executeAsync();
}
Note that using this generic request, you don't receive a GraphUser list as response. You'll need following code to get the response as GraphUser list:
private List<GraphUser> getResults(Response response) {
GraphMultiResult multiResult = response
.getGraphObjectAs(GraphMultiResult.class);
GraphObjectList<GraphObject> data = multiResult.getData();
return data.castToListOf(GraphUser.class);
}
Now you can use your user's friend list, with the information if each of your friends use your Facebook app:
GraphUser user = friends.get(0);
boolean installed = false;
if(user.getProperty("installed") != null)
installed = (Boolean) user.getProperty("installed");
I implemented it in this way
Bundle params = new Bundle();
params.putString("fields", "name, picture, location, installed");
And during displaying of the items on the list,in the getView() method i did this
boolean b = jsonObject.getBoolean("installed");
if (b){
Log.d("VIVEK",jsonObject.getString("name"));
}
I hope this post helps you:
How can i get my friends using my facebook App with graph api asp.net
According to the Facebook SDK, the has_added_app field is deprecated and you should use the is_app_user