无法在 Facebook 上找到朋友的朋友
Cannot get Friends of Friends on facebook
我想从 facebook 获取朋友的朋友,但无法实现。
我关注了 this link(有 3 个赞成票的那个)。每当我尝试访问朋友的朋友时,我都可以得到我的 friendlist.But facebook 返回一个奇怪的 result.Suppose A是B的朋友,B是C的朋友。
我已经在 A、B 和 C.When 的所有设备上安装了我的应用程序,我 运行 我的应用程序作为用户 A,我得到 json 响应,其中包含 Bs details.Then I again hit another url using B
s userid 和这个是时候我必须获取 C.But 的详细信息了 facebook 仅返回 A 的详细信息。
相关代码如下:
下面的异步任务用于检索用户的好友:
我在这里打url :https://graph.facebook.com/me/friends?access_token=USERS_ACCESS_TOKEN
public class GetFriendList extends AsyncTask<String,String,String>
{ private ProgressDialog progressDialog;
protected void onPreExecute() {
super.onPreExecute();
if (progressDialog == null) {
progressDialog = createProgressDialog(MainActivity.this);
progressDialog.show();
} else {
progressDialog.show();
}
}
@Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
// contactList = new ArrayList<HashMap<String, String>>();
//String urlforget="https://graph.facebook.com/"+mediaid+"/friends?access_token="+access_token;
String urlforget="https://graph.facebook.com/me/friends?access_token="+access_token;
System.out.println(urlforget);
ServiceHandle sh = new ServiceHandle();
String jsonStr = sh.makeServiceCall(urlforget, ServiceHandle.GET);
// after getting JSON string from the URL
System.out.println(""+jsonStr);
//Toast.makeText(getBaseContext(), "result:"+jsonStr, Toast.LENGTH_SHORT).show();
try {
if (jsonStr != null)
{
JSONObject jsonobj = new JSONObject(jsonStr);
// Getting JSON Array node
myfriendlist = jsonobj.getJSONArray("data");
// looping through All Contacts
for (int i = 0; i <myfriendlist.length(); i++) {
JSONObject c = myfriendlist.getJSONObject(i);
friendmediaid=c.getString("id");
}
}
} catch (Exception e)
{
e.printStackTrace();
}
return null;
}//doInbacckground
protected void onPostExecute(String file_url) {
progressDialog.dismiss();
new GetFriendofFriendList(friendmediaid).execute();
}//postexecute
}//Asynctask
接下来要从我从上一个异步任务获得的 id 中检索朋友,我点击 url: "https://graph.facebook.com/"+fmediaid+"/friends?access_token="+access_token;
异步任务:
public class GetFriendofFriendList extends AsyncTask<String,String,String>
{ private ProgressDialog progressDialog;
String fmediaid,nurl;
public GetFriendofFriendList(String mediaid,String nurl) {
// TODO Auto-generated constructor stub
this.fmediaid=mediaid;
this.nurl=nurl;
}
protected void onPreExecute() {
super.onPreExecute();
if (progressDialog == null) {
progressDialog = createProgressDialog(MainActivity.this);
progressDialog.show();
} else {
progressDialog.show();
}
}
@Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
// contactList = new ArrayList<HashMap<String, String>>();
System.out.println("2nd async==>"+fmediaid);
String urlforget="https://graph.facebook.com/"+fmediaid+"/friends?access_token="+access_token;
//String urlforget="https://graph.facebook.com/me/friends?access_token="+access_token;
System.out.println(urlforget);
ServiceHandle sh = new ServiceHandle();
String jsonStr = sh.makeServiceCall(urlforget, ServiceHandle.GET);
// after getting JSON string from the URL
System.out.println("Friend of friend===>"+jsonStr);
//Toast.makeText(getBaseContext(), "result:"+jsonStr, Toast.LENGTH_SHORT).show();
return null;
}//doInbacckground
protected void onPostExecute(String file_url) {
progressDialog.dismiss();
}//postexecute
}//Asynctask
但是上面的异步任务正在返回我正在使用该应用程序的配置文件。(如上所述)。
这是我生成访问令牌的方式:
@Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
Toast.makeText(MainActivity.this, session.getAccessToken(), Toast.LENGTH_LONG).show();
System.out.println(session.getAccessToken());
access_token=session.getAccessToken();
所以我做错了什么?为什么 C 没有出现?我已经获得了所有权限并且所有 3 个帐户都接受了 "user_friends" 权限。
有 NO 方法可以通过图表 API 获取朋友的朋友。这是不可能的,并且由于 Graph API v2.0 的附加限制,您甚至只能使用该应用程序的用户朋友。
此外,friends_*
权限已被弃用近一年了。
我想从 facebook 获取朋友的朋友,但无法实现。
我关注了 this link(有 3 个赞成票的那个)。每当我尝试访问朋友的朋友时,我都可以得到我的 friendlist.But facebook 返回一个奇怪的 result.Suppose A是B的朋友,B是C的朋友。
我已经在 A、B 和 C.When 的所有设备上安装了我的应用程序,我 运行 我的应用程序作为用户 A,我得到 json 响应,其中包含 Bs details.Then I again hit another url using B
s userid 和这个是时候我必须获取 C.But 的详细信息了 facebook 仅返回 A 的详细信息。
相关代码如下:
下面的异步任务用于检索用户的好友:
我在这里打url :https://graph.facebook.com/me/friends?access_token=USERS_ACCESS_TOKEN
public class GetFriendList extends AsyncTask<String,String,String>
{ private ProgressDialog progressDialog;
protected void onPreExecute() {
super.onPreExecute();
if (progressDialog == null) {
progressDialog = createProgressDialog(MainActivity.this);
progressDialog.show();
} else {
progressDialog.show();
}
}
@Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
// contactList = new ArrayList<HashMap<String, String>>();
//String urlforget="https://graph.facebook.com/"+mediaid+"/friends?access_token="+access_token;
String urlforget="https://graph.facebook.com/me/friends?access_token="+access_token;
System.out.println(urlforget);
ServiceHandle sh = new ServiceHandle();
String jsonStr = sh.makeServiceCall(urlforget, ServiceHandle.GET);
// after getting JSON string from the URL
System.out.println(""+jsonStr);
//Toast.makeText(getBaseContext(), "result:"+jsonStr, Toast.LENGTH_SHORT).show();
try {
if (jsonStr != null)
{
JSONObject jsonobj = new JSONObject(jsonStr);
// Getting JSON Array node
myfriendlist = jsonobj.getJSONArray("data");
// looping through All Contacts
for (int i = 0; i <myfriendlist.length(); i++) {
JSONObject c = myfriendlist.getJSONObject(i);
friendmediaid=c.getString("id");
}
}
} catch (Exception e)
{
e.printStackTrace();
}
return null;
}//doInbacckground
protected void onPostExecute(String file_url) {
progressDialog.dismiss();
new GetFriendofFriendList(friendmediaid).execute();
}//postexecute
}//Asynctask
接下来要从我从上一个异步任务获得的 id 中检索朋友,我点击 url: "https://graph.facebook.com/"+fmediaid+"/friends?access_token="+access_token;
异步任务:
public class GetFriendofFriendList extends AsyncTask<String,String,String>
{ private ProgressDialog progressDialog;
String fmediaid,nurl;
public GetFriendofFriendList(String mediaid,String nurl) {
// TODO Auto-generated constructor stub
this.fmediaid=mediaid;
this.nurl=nurl;
}
protected void onPreExecute() {
super.onPreExecute();
if (progressDialog == null) {
progressDialog = createProgressDialog(MainActivity.this);
progressDialog.show();
} else {
progressDialog.show();
}
}
@Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
// contactList = new ArrayList<HashMap<String, String>>();
System.out.println("2nd async==>"+fmediaid);
String urlforget="https://graph.facebook.com/"+fmediaid+"/friends?access_token="+access_token;
//String urlforget="https://graph.facebook.com/me/friends?access_token="+access_token;
System.out.println(urlforget);
ServiceHandle sh = new ServiceHandle();
String jsonStr = sh.makeServiceCall(urlforget, ServiceHandle.GET);
// after getting JSON string from the URL
System.out.println("Friend of friend===>"+jsonStr);
//Toast.makeText(getBaseContext(), "result:"+jsonStr, Toast.LENGTH_SHORT).show();
return null;
}//doInbacckground
protected void onPostExecute(String file_url) {
progressDialog.dismiss();
}//postexecute
}//Asynctask
但是上面的异步任务正在返回我正在使用该应用程序的配置文件。(如上所述)。
这是我生成访问令牌的方式:
@Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
Toast.makeText(MainActivity.this, session.getAccessToken(), Toast.LENGTH_LONG).show();
System.out.println(session.getAccessToken());
access_token=session.getAccessToken();
所以我做错了什么?为什么 C 没有出现?我已经获得了所有权限并且所有 3 个帐户都接受了 "user_friends" 权限。
有 NO 方法可以通过图表 API 获取朋友的朋友。这是不可能的,并且由于 Graph API v2.0 的附加限制,您甚至只能使用该应用程序的用户朋友。
此外,friends_*
权限已被弃用近一年了。