Facebook Fan Page Feeds in Android
No Need for Appid,App scrt key etc...
For getting public fan page feed ,use the url
https://www.facebook.com/feeds/page.php?id=PAGE_ID&format=json
No Need for Appid,App scrt key etc...
For getting public fan page feed ,use the url
https://www.facebook.com/feeds/page.php?id=PAGE_ID&format=json
Sample Code:
public class MainActivity extends Activity {
String pageId ="xxxxxxxxxxxx"; InputStream is; String result; String finalPara; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); try { String feed = "https://www.facebook.com/feeds/page.php?id="+pageId+"&format=json"; HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(feed); 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(); System.out.println("feed details "+result); } catch (Exception e) { Log.e("log_tag", "Error converting result " + e.toString()); } }
0 comments: