问题的解决方案
我想出了一个适合我的解决方案。需要存在的东西:
- 在Facebook Developers上注册您的应用
- 该页面需要发布和公开
- 从您注册的应用程序中获取 de APP_ID 和 APP_SECRET ,您可以获得访问令牌,如下所示
https://graph.facebook.com/oauth/access_token?type=client_cred&client_id="+APP_ID+"&client_secret="+APP_SECRET
这是它的代码:
private static final String ACCESS_TOKEN_QUERY = "https://graph.facebook.com/oauth/access_token?type=client_cred&client_id="+APP_ID+"&client_secret="+APP_SECRET;
private static final String FEED_URL = "https://graph.facebook.com/"+PAGE_ID+"/feed?";
private static String accesstoken = "";
private static String jsonresponse = "";
Context context;
String line = null;
final ArrayList<HashMap<String, String>> videolist = new ArrayList<HashMap<String, String>>();
//Get AccessToken
try{
URL url = new URL(ACCESS_TOKEN_QUERY);
URLConnection conn = url.openConnection();
StringBuilder sb = new StringBuilder();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
//read d response till d end
while ((line = rd.readLine()) != null) {
sb.append(line + "\n");
}
accesstoken = sb.toString();
Log.v("log_tag", "Append String " + accesstoken);
} catch (Exception e) {
Log.e("log_tag", "Error converting result " + e.toString());
}
//Get JSON
try{
URL url = new URL(FEED_URL+accesstoken);
URLConnection conn = url.openConnection();
StringBuilder sb = new StringBuilder();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while ((line = rd.readLine()) != null) {
sb.append(line + "\n");
}
jsonresponse = sb.toString();
Log.v("log_tag", "Append String " + jsonresponse);
} catch (Exception e) {
Log.e("log_tag", "Error converting result " + e.toString());
}
//Here you got the jsonresponse now, with which you can go on.
好消息是您甚至不需要在您的应用程序中安装 Facebook SDK。最好的祝福
苹果浏览器