Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
C#
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();
            }
Posted
Updated 19-Aug-16 9:04am
Comments
ZurdoDev 19-Aug-16 7:08am    
I have not interfaced with FaceBook before, but I would imagine there are thousands of examples online of how to do it using c#. I would just find one of the first google results and go with that.
Gautham Prabhu K 19-Aug-16 9:22am    
There are libraries that you can add to your project to do this.
Please google to find out what is the latest library to access FB.
Richard Deeming 19-Aug-16 9:32am    
The profile URL you've provided doesn't exist. Opening the link in Firefox returns:
Sorry, this page isn't available. The link you followed may be broken, or the page may have been removed.

Is it possible that the profile is only visible if you're logged in to Facebook?
Thiago Vaini 19-Aug-16 10:38am    
Have you tried Facebook API for doing this?

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900