我想使用android facebook sdk標記wallpost中的朋友。但是,標籤應該是什麼,是空白的,什麼都不是。這是我所使用的代碼:使用Android Facebook sdk標記wallpost中的朋友sdk
Bundle params = new Bundle();
access_token = fb.getAccessToken();
try {
params.putString("format", "json");
params.putString("access_token", access_token);
String url = "https://graphs.facebook.com/me/friends";
String response = Util.openUrl(url, "GET", params);
JSONObject json = Util.parseJson(response);
JSONArray array = json.optJSONArray("data");
for(int i = 0; i < array.length(); i++) {
String tempName = array.getJSONObject(i).getString("name");
String tempID = array.getJSONObject(i).getString("id");
//Probably should have some if-tests here
if(tempName.contains(*nameOfFriend*)) {
Bundle bundle = new Bundle();
bundle.putString("message", "App tagging test");
//this is where the tagging is supposed to happen
bundle.putString("tags", *UserID*);
try {
fb.request("me/feed", bundle, "POST");
Toast.makeText(getApplicationContext(), "Tag-test", Toast.LENGTH_SHORT).show();
} catch (MalformedURLException e) {
Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_SHORT).show();
e.printStackTrace();
} catch (IOException e) {
Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
} else {
Toast.makeText(getApplicationContext(), "Couldn't find friend", Toast.LENGTH_SHORT).show();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
我只授予「publish_stream」許可,會不會是我需要的其他權限? 在此先感謝您的幫助!
等離子請提供您的問題的解決方案 – jyomin 2014-10-30 05:34:04
@jyomin不幸的是,我從來沒有找到解決方案。此外,我的問題中的代碼現在已過時,因爲它是舊的Facebook SDK。 – Plasma 2014-10-30 10:46:07
好的沒問題,謝謝回覆。 – jyomin 2014-10-31 05:02:58