Android Facebook好友
我正在尝试这个代码,我有问题的是,它只返回单身朋友或注册的朋友 代码: FacebookVariables.fbSession是我的自定义变量Android Facebook好友,android,facebook-graph-api,facebook-friends,Android,Facebook Graph Api,Facebook Friends,我正在尝试这个代码,我有问题的是,它只返回单身朋友或注册的朋友 代码: FacebookVariables.fbSession是我的自定义变量 private void getFriendList() { FRIEND_LIST = new ArrayList<entProductFeedItemsComments>();//array list of class String fqlQuery = "SELECT name,uid,pic FRO
private void getFriendList() {
FRIEND_LIST = new ArrayList<entProductFeedItemsComments>();//array list of class
String fqlQuery = "SELECT name,uid,pic FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1=me()) ORDER BY name";
Bundle _params = new Bundle();
_params.putString("q", fqlQuery);
Session _session = Session.getActiveSession();
Request _request = new Request(_session, "/fql", _params, HttpMethod.GET, new Request.Callback() {
public void onCompleted(Response response) {
GraphObject graphObject = response.getGraphObject();
if (graphObject != null) {
if (graphObject.getProperty("data") != null) {
try {
String _arry = graphObject.getProperty("data").toString();
JSONArray _jsonArray = new JSONArray(_arry);
if (_jsonArray.length() == 0) {
TV_NO_RECORD.setVisibility(View.VISIBLE);
} else {
TV_NO_RECORD.setVisibility(View.GONE);
for (int i = 0; i < _jsonArray.length(); i++) {
JSONObject _jsonObject = _jsonArray.getJSONObject(i);
//fill up your data here
entProductFeedItemsComments _friendList = new entProductFeedItemsComments(getApplicationContext());
_friendList.setUSER_NAME(_jsonObject.getString("name"));
_friendList.setUSER_FRIEND_ID(_jsonObject.getString("uid"));
_friendList.setPROFILE_PICTURE_PATH(_jsonObject.getString("pic"));
FRIEND_LIST.add(_friendList);
}
//Set up your adpter here
PROGRESSBAR.setVisibility(View.GONE);
}
} catch (JSONException ex) {
if (ex != null) {
Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
}
}
}
}
}
});
Request.executeBatchAsync(_request);
PROGRESSBAR.setVisibility(View.VISIBLE);
}
试试这个,让我知道结果 Facebook的政策已经发生了重大变化,现在你只能访问那些已经安装了你的应用程序的朋友的数据,除非你已经获得Facebook的事先许可,通过那里的审批流程。这项新的facebook政策几乎使你自己领域之外的任何数据无效,请阅读这里的新政策以了解更多细节。谢天谢地,这一变化,@Techfist
private void getFriendList() {
FRIEND_LIST = new ArrayList<entProductFeedItemsComments>();//array list of class
String fqlQuery = "SELECT name,uid,pic FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1=me()) ORDER BY name";
Bundle _params = new Bundle();
_params.putString("q", fqlQuery);
Session _session = Session.getActiveSession();
Request _request = new Request(_session, "/fql", _params, HttpMethod.GET, new Request.Callback() {
public void onCompleted(Response response) {
GraphObject graphObject = response.getGraphObject();
if (graphObject != null) {
if (graphObject.getProperty("data") != null) {
try {
String _arry = graphObject.getProperty("data").toString();
JSONArray _jsonArray = new JSONArray(_arry);
if (_jsonArray.length() == 0) {
TV_NO_RECORD.setVisibility(View.VISIBLE);
} else {
TV_NO_RECORD.setVisibility(View.GONE);
for (int i = 0; i < _jsonArray.length(); i++) {
JSONObject _jsonObject = _jsonArray.getJSONObject(i);
//fill up your data here
entProductFeedItemsComments _friendList = new entProductFeedItemsComments(getApplicationContext());
_friendList.setUSER_NAME(_jsonObject.getString("name"));
_friendList.setUSER_FRIEND_ID(_jsonObject.getString("uid"));
_friendList.setPROFILE_PICTURE_PATH(_jsonObject.getString("pic"));
FRIEND_LIST.add(_friendList);
}
//Set up your adpter here
PROGRESSBAR.setVisibility(View.GONE);
}
} catch (JSONException ex) {
if (ex != null) {
Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
}
}
}
}
}
});
Request.executeBatchAsync(_request);
PROGRESSBAR.setVisibility(View.VISIBLE);
}