Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
1 down vote favorite
1


I am working on a simple Windows Forms program that take a username and password from a "Textbox" then it show my linked-in name in a "Messagebox".

I want to accomplish the code with the using of "HttpWebRequest" or using any method to send my POST request to Linked-in then i can get the response and find my name to shown it in a "Messagebox".

I am familiar with creating a "GET" Request and also i made some "POST" Requests but in this case i didn't know how can i send my "txt_UserName.Text" and "txt_Password" with the POST Request and how can i receives the Response.

i tried to using Fiddler to capture POST request (=POST) from linkedin when i try to login but it captures more than 4 requests when i see the header of them it seem like a GET Request this is an example of one:

GET /nhome/?trk= HTTP/1.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8


and all of them have a multiple cookies values.

This is my POST request code:

C#
public void SubmitData()
    {
        try
        {

            string postData = "This is a test that posts this string to a Web server.";
            byte[] byteArray = Encoding.UTF8.GetBytes(postData);

            // Create a request using a URL that can receive a post. 
            WebRequest request = WebRequest.Create("http://www.linkedin.com");
            // Set the Method property of the request to POST.
            request.Method = "POST";
            // Set the ContentLength property of the WebRequest.
            request.ContentLength = byteArray.Length;
            //Content Length
            request.ContentLength = byteArray.Length;

            // Get the request stream.
            Stream dataStream = request.GetRequestStream();
            // Write the data to the request stream.
            dataStream.Write(byteArray, 0, byteArray.Length);
            // Close the Stream object.
            dataStream.Close();

            // Get the response.
            WebResponse response = request.GetResponse();
            dataStream = response.GetResponseStream();

            StreamReader sr = new StreamReader(dataStream);
            MessageBox.Show(sr.ReadToEnd());

            sr.Close();
            dataStream.Close();




        }
        catch (Exception ex)
        {
            MessageBox.Show("Error: " + ex.Message);
        }
    }


Now the only thing i whish to know, how can i send my username and password as a values to login to linked-in?
Posted
Comments
Maciej Los 5-Nov-14 14:57pm    
Do you want to log in into LinkedIn site or to get user names from this site?
BillWoodruff 6-Nov-14 5:56am    
Repost of:

http://www.codeproject.com/Questions/835605/How-Can-I-Login-To-Linkedin-Using-Crawl-In-Csharp?arn=0

?

1 solution

Look at the documentation on linkedIn:

https://developer.linkedin.com/documents/authentication[^]
 
Share this answer
 

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