Posted 11 years ago
·
Author
This is c# code for logging into IMVU with your program. You can find the Vb.net equivalent here: https://www.imvumafias.org/community/viewtop ... 109&t=8487
Note: This code now needs .Net 4.6 to work with IMVU's SSL update.
This is the minimum amount of code you need to log into IMVU. If you want to make this really useful I recommend creating a CookieContainer property and storing the cookies from the login response so you can use it to make further calls to IMVU for data.
Note: This code now needs .Net 4.6 to work with IMVU's SSL update.
string s = "POSTDATA=sauce=&avatarname=" + UserName + "&password=" + Password + "&password_strength=strong&sendto=";
CookieContainer cookieContainer = new CookieContainer();
byte[] bytes = new UTF8Encoding().GetBytes(s);
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("https://secure.imvu.com/login/login/");
httpWebRequest.Method = "POST";
httpWebRequest.KeepAlive = true;
httpWebRequest.CookieContainer = cookieContainer;
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
httpWebRequest.Referer = "http:www.imvu.com/login/";
httpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1";
httpWebRequest.ContentLength = (long)bytes.Length;
httpWebRequest.AllowAutoRedirect = false;
try
{
using (Stream requestStream = httpWebRequest.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Length);
using (WebResponse response = httpWebRequest.GetResponse())
{
CookieCollection Cookies = ((HttpWebResponse)response).Cookies;
//Check for a valid login cookie
if (Cookies != null || Cookies["_imvu_avnm"] != null)
{
return true;
}
}
return false;
}
}
catch (WebException)
{
return false;
}
This is the minimum amount of code you need to log into IMVU. If you want to make this really useful I recommend creating a CookieContainer property and storing the cookies from the login response so you can use it to make further calls to IMVU for data.