me/friends empty friend list - android

I am trying to get friend list using me/frineds tag. There is no user of the app so far so i have added some frirneds as a tester of the app. But they are not showing in the response i am getting empty data list. Please guide me what i am doing wrong here. Here is the code
Bundle required = new Bundle();
required.putString("fields", "id, name, picture.type(square), gender, email");
//Request for friendlist from facebook
Request req = new Request(session, "me/friends", required, HttpMethod.GET,
new Callback() {
#Override
public void onCompleted(Response response)
{
is2=response.getGraphObject();
JSONObject json = is2.getInnerJSONObject();
readResponse(json);
String str = json.toString();
saveFileOnSD("data", str);
// generateNoteOnSD("frinedresponse", str);
Log.v(TAG, str);
}
});
Request.executeBatchAsync(req);

With v2.0, only users who are using the App too show up in the friend list. It is not enough to add someone as Tester in the App Settings, a user has to authorize your App.
See changelog for more information: https://developers.facebook.com/docs/apps/changelog
There is also "invitable_friends" and "taggable_friends", the first one is for game invitations only and the second one is for tagging only.

This has been previously asked, and the thread listed below has a ton of details. The only work around is if your app is a game. Here is the link to the other post: Facebook Graph Api v2.0+ - /me/friends returns empty, or only friends who also use my app

Related

Is GraphObject can be used with ShareDiaog in android

I've used GraphObject to share user story here is my object.
Bundle params = new Bundle();
params.putString("reward", permaLink);
params.putBoolean("fb:explicitly_shared", true);
GraphRequest request = new GraphRequest(
MainActivity.getInstance().mSimpleFacebook.getAccessToken(),
"me/rewardster:redeem",
params,
HttpMethod.POST,
new GraphRequest.Callback() {
#Override
public void onCompleted(GraphResponse graphResponse) {
Log.i(TAG, graphResponse.toString());
}
}
);
request.executeAsync();
It works fine, is it possible for me to share it via ShareDialog, so user can add text to it or tag someone from friend list. etc?
If my current code is not good with share dialog please help me translating my graph object to some other model which is compatible with share dialog.
Its possible in IOS by the way.
There must be some way out of it in android as well.
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
action.actionType = #"rewardster:redeem";
[action setString:rewardObj.fbStoryLink forKey:#"reward"];
FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = #"reward";
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:self];
NO, if you use share dialog you cant customize much[there is few flexibilty], hence to customize the post as a story and add custom fields and to modify the post we use graph stories check out the link https://developers.facebook.com/docs/sharing/opengraph. Both allows you to share but the post will look different.
to create a custom graph story refer this link
https://developers.facebook.com/docs/sharing/opengraph/custom
To achieve those custom things that you have asked you need to use graph-api only

Can an Android app make a post on Facebook and later get the number of likes on that post?

I want my app to post on Facebook and later query that same post, so that I can find the number of likes it received.
Is it possible? How do we do it?
Publishing API documentation from Facebook
The result is the post id, so just save this somewhere in the local storage with other post ids.
When you want to get the number of likes, use:
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{YOUR_POST_ID}/likes",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
You must set summary = true
This returns a summary element with a total_count field.
Documentation can be found here

Facebook - Android - Total Likes - Graph API

I'm attempting to retrieve the total number of likes for a selected Facebook Page POST
According to this page:
How to get Likes Count when searching Facebook Graph API with search=xxx
I've tried to refer to the answers in that post and to build my code based on that.Here's the current code that I have based on it
private void totalLikes(String post_id){
Bundle bun = new Bundle();
bun.putString("summary","true");
new Request(Session.getActiveSession(), post_id+"/likes/",bun, HttpMethod.POST,
new Request.Callback() {
#Override
public void onCompleted(Response response) {
Toast.makeText(getBaseContext(),String.valueOf(response),Toast.LENGTH_SHORT).show();
}
}).executeAsync();
}
Unfortunately the response given is not what was expected,I was thinking that it could be due to my Bundle parameters.So I would like to know what are the actual bundle parameters I should be putting for the code?Thank you for the help :)!
In your Bundle string addition, try changing it to bun.putString("fields","likes.summary(true)"); and change the graph path to just the post_id. There should end up being a "summary" field in the response after that.
EDIT: Here's another method that might work better with permissions.
Graph path: post_id + "/likes"
with
bun.putString("include_summary", "true");
I tried messing around in the explorer and couldn't get it to work, but you might have better luck.

Android - fql getting id from album not working in sdk 3.5

I have made a lot of combinations to get this working but I'm always getting an empty json, however in the Graph API Explorer it works very well, I'm using this statement to get the id of the albums from a X user:
SELECT aid from album WHERE owner = XXXXXXXXXX
it is returning (for example):
{
"data": [
{
"aid": "xxxxxxx_xxxx"
},
{
"aid": "xxxxxxxx_xxx"
}
]
}
in the drop down menu (where normally is Graph Api explorer selected) I have changed for my app, also I'm using the button "get access token" and selecting: "user_photos","friends_photos","user_friends" permissions,
but in my android app only I retrieve an empty json, (note: I have used another statement to recover user data (such as birthday) with this code, and works fine so code is correct, note2: I'm using the "user_photos","friends_photos","user_friends" permissions inside the app).
the code of the app (the fragment) is:
mynewbutton = (Button) view.findViewById(R.id.mynewbutton);
mynewbutton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(final View v) {
String fqlQuery = "SELECT aid from album WHERE owner = XXXXXXXXX";
Bundle params = new Bundle();
params.putString("q", fqlQuery);
Session session = Session.getActiveSession();
// params.putString("access_token", session.getAccessToken());
Request request = new Request(session,
"/fql",
params,
HttpMethod.GET,
new Request.Callback(){
public void onCompleted(Response response) {
//Log.i(TAG, "Result: " + response.toString());
}
});
Request.executeBatchAsync(request);
}
});
Possible the reason is cuz I'm not getting the "valid access_token" inside the app.
So it came some questions in mind:
1.-How do I get the access_token?
2.-Do I need to use the method getAccessToken()?
3.-If so, How do I integrate in my code?
4.-Is it necessary to change something in the Graph Api Explorer in order to get working well in the app?
5.- Am I missing something (a step or a piece of code for example)?
6.-In general, How do I get the aid from album inside my app just like in the Graph Api Explorer? thanks.

Posting to Facebook specific friend list using Facebook android SDK

I am successfully posting to Facebook wall, but I want that user can choose whether they want to post it to some specific friend list e.g. Acquaintances, Family etc
My code is giving this error :
{"error":{"message":"(#100) privacy must contains a valid privacy 'value'","type":"OAuthException"}}
I have added "privacy" attribute and have given it value of "Family", but its not working, but if I remove the privacy attribute, the wall post is successful
try
{
Bundle parameters = new Bundle();
parameters.putString("message", msg);
parameters.putString("description", "Test 1");
JSONObject jsonObject = new JSONObject();
jsonObject.put("value", "Family");
parameters.putString("privacy", jsonObject.toString());
response = Data.facebook.request("me/feed", parameters,"POST");
} catch(Exception e) {
e.printStackTrace();
}
The value field may specify one of the following strings:
EVERYONE, ALL_FRIENDS, NETWORKS_FRIENDS, FRIENDS_OF_FRIENDS, CUSTOM .
The friends field must be specified if value is set to CUSTOM and
contain one of the following strings: EVERYONE, NETWORKS_FRIENDS (when
the object can be seen by networks and friends), FRIENDS_OF_FRIENDS,
ALL_FRIENDS, SOME_FRIENDS, SELF, or NO_FRIENDS (when the object can be
seen by a network only).
The allow field must be specified when the friends value is set to
SOME_FRIENDS and must specify a comma-separated list of user IDs and
friend list IDs that 'can' see the post.
Try this instead, but you will need to know the friendlists ID for Family.
var theFriendLists = Api.Get(`me/friendlist`);
var theFriendsListIdForFamily = theFriendLists.Select item where list_type=="family";
JSONObject jsonObject = new JSONObject();
jsonObject.put("value", "CUSTOM");
jsonObject.put("friends", "SOME_FRIENDS");
jsonObject.put("allow", theFriendsListIdForFamily);
parameters.putString("privacy", jsonObject.toString());

Categories

Resources