Search code examples
c#authenticationhttpwebrequest

C# How to log in by code to social network site geni.com


I have read several posts about login in to sites that needs email and password, but i couldn't find a solution about logging in to a specific site called geni.com. Is there a way?

CookieContainer cookie;
string user = "somemail@somehost.com";
string pass = "123456";

string formUrl = "http://www.geni.com/login/";
string formParams = String.Format("profile_username={0}&password={1}", "MYUSERNAME", "MYPASS");
string cookieHeader;
HttpWebRequest myWebRequest;
WebResponse myWebResponse; 
String URL = textBox1.Text;
myWebRequest = (HttpWebRequest)WebRequest.Create("formUrl");
myWebRequest.ContentType = "application/x-www-form-urlencoded";
myWebRequest.Method = "POST";
string login = string.Format("go=&Fuser={0}&Fpass={1}", user, pass);

byte[] postbuf = Encoding.ASCII.GetBytes(login);


 myWebResponse = myWebRequest.GetResponse(); //Returns a response from an Internet resource
cookieHeader = myWebResponse.Headers["Set-cookie"];
cookie = myWebRequest.CookieContainer = new CookieContainer();
myWebRequest.CookieContainer = cookie;
Stream streamResponse = myWebResponse.GetResponseStream(); 
                                                        
StreamReader sreader = new StreamReader(streamResponse);
Rstring = sreader.ReadToEnd();

I am a bit confused, can anybody help me??


Solution

  • Here's a link to their API documentation. To login you'll want to call their API like this:

    https://www.geni.com/platform/oauth/request_token?client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&grant_type=client_credentials