通过C#打开Facebook个人资料
问题描述:
大家好。
为什么我想在我的应用程序中打开某些个人资料,我有些严重的头痛。
当我打开它时,我得到的信息是页面不存在,当我在浏览器中打开它并且工作正常。
你能否告诉我如何重新编写代码一块?
我尝试了什么:
这是我的意思试过。这是现有的配置文件,但是当我用这个代码打开它时没有。
Hello guys.
I am under some serious headaches why some profiles that I want to "open" in my app.
When I open them I get message that the page is not present, when I open it in browser and works perfectly.
Could you give me advise how to rework the code piece?
What I have tried:
Here is what I have tried. This is existing profile but when I open it with this code does not.
Uri profileUri = new Uri(@"https://www.facebook.com/roger");
HttpWebRequest httpWebRequest = (HttpWebRequest) WebRequest.Create(profileUri);
httpWebRequest.Method = WebRequestMethods.Http.Get;
httpWebRequest.Proxy = null;
httpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2";
httpWebRequest.AllowWriteStreamBuffering = true;
httpWebRequest.ProtocolVersion = HttpVersion.Version11;
httpWebRequest.AllowAutoRedirect = true;
httpWebRequest.KeepAlive = false;
httpWebRequest.ContentType = "text/html";
httpWebRequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
using (HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse())
using (StreamReader sr = new StreamReader(response.GetResponseStream()))
{
source = sr.ReadToEnd();
}
答
尝试FB API:
GitHub - Microsoft / winsdkfb:适用于Facebook的Windows SDK允许开发人员为Windows Apps提供Facebook集成。 [ ^ ]
Try FB API:
GitHub - Microsoft/winsdkfb: The Windows SDK for Facebook allows developers to provide Facebook integration for Windows Apps.[^]