Reputation: 5363
I have a problem with the list of taggable friends, this is my code , that with the old sdk worked great.
public void getTaggableFriends(){
Session activeSession = Session.getActiveSession();
if(activeSession.getState().isOpened()){
new Request(
activeSession,
"/me/taggable_friends",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
GraphObject graphObject = response.getGraphObject();
if (graphObject != null) {
JSONObject jsonObject = graphObject.getInnerJSONObject();
String taggableFriendsJson = jsonObject.toString();
Gson gson = new Gson();
TaggableFriendsWrapper taggableFriendsWrapper= gson.fromJson(taggableFriendsJson, TaggableFriendsWrapper.class);
ArrayList<TaggableFriends> invitableFriends = new ArrayList<TaggableFriends>();
invitableFriends = taggableFriendsWrapper.getData();
int i;
for(i = 0; i < invitableFriends.size(); i++)
{
try
{
MainActivity.myMenu.add(invitableFriends.get(i).getName());
}
catch(Exception e){}
}
MainActivity.myMenu.add("Tot: " + i);
}else {
}
//response.get
}
}
).executeAsync();
}
}
get to the point , how can I adapt SDK 4.0 ? Or is there some other way to do this ?? I would not know where to start, thanks in advance.
Upvotes: 2
Views: 600
Reputation: 416
Now it wont work
As of facebook doc the User Taggable Friend node was deprecated on April 4th, 2018 and now returns an empty data set.
https://developers.facebook.com/docs/graph-api/reference/user-taggable-friend/
Upvotes: 0
Reputation: 1428
You can simply change it to
if(AccessToken.getCurrentAccessToken() != null)
{
GraphRequest graphRequest = GraphRequest.newGraphPathRequest(
AccessToken.getCurrentAccessToken(),
"me/taggable_friends",
new GraphRequest.Callback()
{
@Override
public void onCompleted(GraphResponse graphResponse)
{
//Your code
if(graphResponse != null)
{
JSONObject jsonObject = graphResponse.getJSONObject();
String taggableFriendsJson = jsonObject.toString();
Gson gson = new Gson();
TaggableFriendsWrapper taggableFriendsWrapper= gson.fromJson(taggableFriendsJson, TaggableFriendsWrapper.class);
ArrayList<TaggableFriends> invitableFriends = new ArrayList<TaggableFriends>();
invitableFriends = taggableFriendsWrapper.getData();
int i;
for(i = 0; i < invitableFriends.size(); i++)
{
try
{
MainActivity.myMenu.add(invitableFriends.get(i).getName());
}
catch(Exception e){}
}
MainActivity.myMenu.add("Tot: " + i);
}else {
}
//response.get
}
}
);
Bundle parameters = new Bundle();
parameters.putInt("limit", 5000); //5000 is maximum number of friends you can have on Facebook
graphRequest.setParameters(parameters);
graphRequest.executeAsync();
}
Upvotes: 1