我的朋友使用此代码。搜索并进行一些研究,此代码在我的项目中工作。
public void harhar(){
HttpClient httpclient = new DefaultHttpClient();
String url = "https://graph.facebook.com/me/friends?access_token=" + URLEncoder.encode(access_token);
HttpGet httppost = new HttpGet(url);
try {
HttpResponse response = httpclient.execute(httppost);
// to get the response string
BufferedReader reader = new BufferedReader(
new InputStreamReader(
response.getEntity().getContent(), "UTF-8"));
// used to construct the string
String res = "";
for (String line = null; (line = reader.readLine()) != null;) {
res += line + "\n";
}
JSONObject obj = new JSONObject(new JSONTokener(res));
JSONArray data = obj.getJSONArray("data");
Log.i("DATA",data+"");
int len = data.length();
for (int i = 0; i < len; i++) {
JSONObject currentResult = data.getJSONObject(i);
String name = currentResult.getString("name");
String id=currentResult.getString("id");
Log.i("Name harharhar",name);
Log.i("ID harharhar",id);
namelist.add(name);
IDList.add(id);
}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
我得到了我的朋友的身份证和姓名。我制作listview并存储名称。现在我想知道如何将messenge发送到朋友的facebook收件箱。请帮忙。