通过C#打开Facebook个人资料 [英] Opening Facebook profile via C#

查看:69
本文介绍了通过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:



< a href =https://github.com/Microsoft/winsdkfb> 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.[^]


这篇关于通过C#打开Facebook个人资料的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆