[英]How to get online friends who are currently using my application through Facebook sdk android
I created an android application which has Facebook login and I have been trying to get my friends who are currently using my application. 我创建了一个具有Facebook登录名的android应用程序,并且我一直在尝试让我当前正在使用我的应用程序的朋友。 This means I want to get my friends who are currently online in my app. 这意味着我想让我的应用程序中当前在线的朋友。 I tried multiple ways and all of them are giving me the online_presence as "offline" every time though some of my friends are online. 我尝试了多种方法,每次我的一些朋友在线时,所有这些方法都使我以online_presence作为“离线”。 Some of the methods I tried are 我尝试过的一些方法是
1. Added permissions (user_onlinepresence, friends_online presence, user_status) in app-appdetails- configure app center permissions. ----didn't work.
2.SELECT uid, name, online_presence FROM user WHERE online_presence IN ('active', 'idle') AND uid IN (SELECT uid2 FROM friend WHERE uid1 = 1234)&access_token=xxxxxxtokenxxxxx&method=GET--- gives me empty data(though many of friends using my app are online.) 2.从用户那里选择uid,名称,online_presence在哪里online_presence IN('active','idle')和uid IN(从朋友那里SELECT uid2 uid1 = 1234)&access_token = xxxxxxtokenxxxxx&method = GET ---给了我空数据(尽管很多使用我的应用程序的朋友处于在线状态。)
I googled so much about this. 我用谷歌搜索了很多。 But didn't get any solution which is working. 但是没有任何有效的解决方案。 I request you all to help me in this issue and would provide a solution which could work for me. 在此问题上,我要求大家提供帮助,并提供一个对我有用的解决方案。
With the new version of GraphRequest is very simple, just add this method: 使用新版本的GraphRequest非常简单,只需添加以下方法:
private String[] getUserContacts(){
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me/friends",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
try {
JSONArray rawContactsData = response.getJSONObject().getJSONArray("data");
contacts=new String[rawContactsData.length()];
for (int j = 0; j < rawContactsData.length(); j++) {
JSONObject item = rawContactsData.getJSONObject(j);
contacts[j]=item.getString("id");
}
Log.d("Contacts","ala"+rawContactsData);
getCalendarData();
}catch (JSONException e){
}
}
}
).executeAsync();
return contacts;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.