마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

페이스북연동 데이터가져오기 질문

0 추천

페이스북과연동해서 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();
핔미 (140 포인트) 님이 2016년 5월 12일 질문

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...