I am trying to get facebook page feed ( public posts) which does not require any access token. here's the url https://www.facebook.com/feeds/page.php?format=json&id=1393547494231876 when i run this in browser where id= any facebook page id. it returns first 25 public posts in json format. but when i run this in my code to get json result facebook return a page saying "unsupported browser" this is my method . i pass it facebook page id to get posts..
public static String GetPosts(string PageId)
{
string id = PageId;
string apilink = "https://www.facebook.com/feeds/page.php?format=json&id=";
HttpWebRequest request = WebRequest.Create(apilink + id) as HttpWebRequest;
request.Method = WebRequestMethods.Http.Get;
request.Accept = "application/json";
request.ContentType = "application/json; charset=utf-8";
// Get response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
// Get the response stream
StreamReader reader = new StreamReader(response.GetResponseStream());
// Console application output
String result = reader.ReadToEnd();
return result;
}
}
Here's the result that i get in return string Result Image String
and so on remaining page returned. Can somebody help me how to get it working??
Update Found Answer... I Have To Set User agent to make Facebook think i am a browser.. so just added request.UserAgent = ".NET Framework"; and i worked. Thanks to All.