Getting AccessToken Using App id, App Secret Key of facebook app
use the url
https://graph.facebook.com/oauth/access_token? type=client_cred&client_id="+appId+"&client_secret="+appSecret
use the url
https://graph.facebook.com/oauth/access_token? type=client_cred&client_id="+appId+"&client_secret="+appSecret
Sample Code:
public static String getAccessToken() { InputStream is = null; String result = ""; String url; String urlParameters = null; try { url = "https://graph.facebook.com/oauth/access_token?type=client_cred&client_id="+appId+"&client_secret="+appSecret; System.out.println("url is "+url); HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); is = entity.getContent(); } catch (Exception e) { Log.e("log_tag", "Error in http connection " + e.toString()); } // convert response to string try { BufferedReader reader = new BufferedReader(new InputStreamReader( is, "iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } is.close(); result = sb.toString(); } catch (Exception e) { Log.e("log_tag", "Error converting result " + e.toString()); } return result; }
0 comments: