Reputation: 531
I want my app to get ids and names of user's friends that have used the app too and find the id I need by the name. Then I want to use feed dialog with parameter "TO" to post to friend's wall. I thought it would be easy. Just use me/friends
. Here is request:
if(session.getState().isOpened()){
Log.i(TAG, "Creating request");
Request friendRequest = new Request(session, "/me/friends", null, HttpMethod.GET, new Request.Callback() {
public void onCompleted(Response response) {
Log.w(TAG, "Complete!" + response.toString());
JSONArray usersArrays = new JSONArray();
try {
Log.i(TAG, "Converting to userObject");
usersArrays = response.getGraphObject().getInnerJSONObject().getJSONArray("data");
for (int i = 0; i < usersArrays.length(); i++){
Log.i(TAG, "Reading " + i + " user");
JSONObject user = usersArrays.getJSONObject(i);
Log.i(TAG, "Getting name and id");
String userId = user.getString("id");
String userName = user.getString("name");
Log.i(TAG, "Now checking: " + userName + " with id: " + userId);
if (userName.equals(name)){
Log.w(TAG, "He was found! Here is his id: " + userId);
postToWall(userId);
} else if (i == (usersArrays.length() - 1)){
Log.e(TAG, name + " does not use the app yet!");
//no ways
}
}
} catch (JSONException e) {
Log.e(TAG, "Error: " + e);
Toast.makeText(context, "Error", Toast.LENGTH_LONG).show();
}
}
}
);
Log.i(TAG, "Sending request");
friendRequest.executeAndWait();
Here is my response:
{Response: responseCode: 200, graphObject: GraphObject{graphObjectClass=GraphObject, state={"summary":{"total_count":46},"data":[{"id":"383791018465143","name":"Friend Name"}],"paging":{"next":"..."}}}, error: null, isFromCache:false}
Then I found this site and decided to find out friend's id. It was not the same.
When using feed dialog my app crashes with facebook error: incorrect user
. What can I do about it?
Thanks in advance, Sergey
Upvotes: 0
Views: 292