페이스북과연동해서 post의 id와 created_time,comments의 id와 message를 가져오는
코드를 짜고있는데 오류가나고있어서(앱이중지되고꺼지는)..어떤부분이오류인지 이부분에필요한 권한이 따로있는건지 잘 모르겠어서
onSuccess함수에 추가했는데 한번 봐주십사합니다.
GraphRequest request=new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me?fields=posts{id,message,comments{id,message},created_time}",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
final JSONObject jsonObject=response.getJSONObject();
try {
JSONObject posts=jsonObject.getJSONObject("posts");
JSONArray posts_data=posts.getJSONArray("data");
///페북포스트아이디 코멘트아이디및내용가져오기 /
int postCount=posts_data.length();
comparedPostsComments[] compared=new comparedPostsComments[postCount];
for(int i=0;i<posts_data.length();i++){
//post_id와 post created_time가져오기
compared[i].postID=posts_data.getJSONObject(i).getString("id");
compared[i].createdTime=posts_data.getJSONObject(i).getString("created_time");
//comments 데이터
JSONObject comments=posts_data.getJSONObject(i).getJSONObject("comments");
JSONArray comments_data=comments.getJSONArray("data");
compared[i].setCommentsCount(comments_data.length());
for(int j=0;j<comments_data.length();j++){
//comments_id와 messeage내용
compared[i].commentID[j]= comments_data.getJSONObject(j).getString("id");
compared[i].commentMessage[j]= comments_data.getJSONObject(j).getString("message");
// Log.d("commentMessage",compared[i].commentMessage[j]);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
);
request.executeAsync();