問題の解決策
私の場合、解決策の魔女が機能することがわかりました。存在する必要があるもの:
- Facebook Developersにアプリを登録する
- ページを公開して公開する必要があります
- 登録したアプリから 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 を含める必要さえないことです。よろしくお願いします
サファリ