2013-11-15 4 views
0

나는 내 애플 리케이션에 페이스 북 SDK를 통합하고 있습니다. 사용자의 친구 이름과 생일을 알아야합니다. "read_friendlists", "user_birthday", "user_friends", "friends_birthday"를 추가했습니다.페이스 북의 친구 생일

앱의 Admin 페이 스북 ID로 로그인하면 생년월일 목록을 올바르게 가져올 수 있습니다. 하지만 다른 계정으로 로그인하면 JSON 응답에 생일 필드가 없습니다.

추신 : 이미 샌드 박스 모드를 사용 중지했습니다. 앱 대시 보드에서 "이 앱은 실시간으로 (모든 사용자가 볼 수 있음)"을 표시합니다.

+0

당신은 너무 [여기]이 게시물을 볼 수 있습니다 [1] [1] 권한을 포함하는 배열입니다/questions/14000802/android-getting-friends-birthday-using-graph-api-facebook-sdk-3-0? rq = 1 –

답변

0

JSON 개체에 대해서는 Google에서 도와 드릴 수있는 코드를 입력하십시오. 나는 페이스 북 사용자 생일을 얻으려면이 사람을 사용하십시오. 먼저 user_birthday에 대한 권한을 설정 했습니까? 사용자가 일반적으로 당신이 user.getBirthday()에 의해 생일을 얻을 수 있습니다 null가 아닌 경우, 당신은 user_birthday 정보를

액세스하려는 경우가 있기 때문에 당신이 새로운 페이스 북 SDK를 사용하고 무엇을보고에서 매우 중요

당신에게 당신은 페이스 북의 authbutton

authButton.setReadPermissions(Arrays.asList("user_location", "user_birthday", "user_likes")); 

을 사용하거나 권한

Session.ReauthorizeRequest reauthRequest = new Session.ReauthorizeRequest(this, PERMISSIONS). 
       setRequestCode(REAUTHORIZE_ACTIVITY). 
       setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK); 
session.reauthorizeForPublish(reauthRequest); 

을 재 인증 할 수있을 때, 예를 들어 권한을 설정할 수 있습니다 http://stackoverflow.com : 권한

+0

답장을 보내 주셔서 감사합니다 ... 사용자의 친구 생일을 보내고 싶습니다. 사용자 ... – lingareddyk

0

확인하려고이

String[] facebook_permissions = { "user_photos", "friends_birthday", "friends_photos" }; 

========================================================================== 

public class FriendListAdapter extends BaseAdapter implements SectionIndexer { 
private LayoutInflater mInflater; 
private String[] sections; 
private GetProfilePictures picturesGatherer = null; 
FriendsList friendsList; 
Hashtable<Integer, FriendItem> listofshit = null; 

public FriendListAdapter(FriendsList friendsList) { 
    Log.d(LOG_TAG, "FriendListAdapter()"); 
    this.friendsList = friendsList; 
    sections = new String[getCount()]; 
    listofshit = new Hashtable<Integer, FriendItem>(); 
    for (int i = 0; i < getCount(); i++) { 
     try { 
    sections[i] = jsonArray.getJSONObject(i).getString("name").substring(0); 
sections[i] = jsonArray.getJSONObject(i).getString("birthday").substring(1); 
     } catch (JSONException e) { 
      sections[i] = ""; 
      Log.e(LOG_TAG, "getJSONObject: " + e.getMessage()); 
     } 
    } 
    if (picturesGatherer == null) { 
     picturesGatherer = new GetProfilePictures(); 
    } 
    picturesGatherer.setAdapterForListener(this); 
    mInflater = LayoutInflater.from(friendsList.getBaseContext()); 
} 

public int getCount() { 
    Log.d(LOG_TAG, "getCount()"); 
    if (jsonArray == null) 
     return 0; 
    return jsonArray.length(); 
} 

public Object getItem(int position) { 
    Log.d(LOG_TAG, "getItem()"); 
    return listofshit.get(position); 
} 

public long getItemId(int position) { 
    Log.d(LOG_TAG, "getItemId()"); 
    return position; 
} 

public View getView(int position, View convertView, ViewGroup parent) { 
    Log.d(LOG_TAG, "getView(" + position + ")"); 

    JSONObject jsonObject = null; 
    try { 
     jsonObject = jsonArray.getJSONObject(position); 
    } catch (JSONException e) { 
     Log.e(LOG_TAG, "getJSONObject: " + e.getMessage()); 
    } 

    FriendItem friendItem; 

    if (convertView == null) { 
     convertView = mInflater.inflate(R.layout.single_friend, null); 
     friendItem = new FriendItem(); 

     convertView.setTag(friendItem); 
    } 
    else { 
     friendItem = (FriendItem) convertView.getTag(); 
    } 

    friendItem.friendPicture = (ImageView) convertView.findViewById(R.id.picture_square); 
    friendItem.friendName = (TextView) convertView.findViewById(R.id.name); 
    friendItem.friendDob = (TextView) convertView.findViewById(R.id.dob); 
    friendItem.friendLayout = (RelativeLayout) convertView.findViewById(R.id.friend_item); 

    try { 
     String uid = jsonObject.getString("uid"); 
     String url = jsonObject.getString("pic_square"); 
     friendItem.friendPicture.setImageBitmap(picturesGatherer.getPicture(uid, url)); 
    } catch (JSONException e) { 
     Log.e(LOG_TAG, "getJSONObject: " + e.getMessage()); 
     friendItem.friendName.setText(""); 
     friendItem.friendDob.setText(""); 
    } 

    try { 
     friendItem.friendName.setText(jsonObject.getString("name")); 
     friendItem.friendDob.setText(jsonObject.getString("birthday")); 
    } catch (JSONException e) { 
     Log.e(LOG_TAG, "getJSONObject: " + e.getMessage()); 
     friendItem.friendName.setText(""); 
     friendItem.friendDob.setText(""); 
    } 

    listofshit.put(position, friendItem); 

    return convertView; 
} 

public int getPositionForSection(int position) { 
    return position; 
} 

public int getSectionForPosition(int position) { 
    return position; 
} 

public Object[] getSections() { 
    return sections; 
} 
} 

class FriendItem { 
TextView friendDob; 
int id; 
ImageView friendPicture; 
TextView friendName; 
RelativeLayout friendLayout; 

} 

============================================================================== 

String query = "select name, uid, pic_square, birthday from user where uid in 
(select uid2 from friend where uid1=me()) order by name"; 
+0

그리고 당신 도이 게시물을 볼 수 있습니다 여기 [link] (http://stackoverflow.com/questions/14000802/android-getting-friends-birthday-using- 그래프 -API-facebook-sdk-3-0? rq = 1) –

관련 문제