[C#] Imvu Login Code - Source [Updated 4-28-2014] 9 posts

OP Mon Apr 28, 2014 5:15 pm
User avatar
Administrator
Legendary Family Member
  • Gender: Male
  • Posts: 6284
  • Joined: Jun, 2010
  • Advertisements: 45
  • Karma: 368
This is c# code for logging into IMVU with your program. You can find the Vb.net equivalent here: http://imvumafias.org/community/viewtop ... 109&t=8487

Note: This code now needs .Net 4.6 to work with IMVU's SSL update.

Code
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.
Thu May 08, 2014 3:13 am
User avatar
  • Gender: Male
  • Posts: 42
  • Joined: May, 2014
  • Karma: 0
Thanks, needed this
Sun Jul 12, 2015 11:58 pm
User avatar
Inner Family Member
  • Gender: Male
  • Posts: 209
  • Joined: Sep, 2011
  • Karma: 0
D.M wrote:
This is c# code for logging into IMVU with your program. You can find the Vb.net equivalent here: http://imvumafias.org/community/viewtop ... 109&t=8487Login Cookie Declaration:
Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)CookieContainer LoginCookie = new CookieContainer();GeSHi ©Sub Code:
Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)string postData = "POSTDATA=sauce=&avatarname=" + UsernameBx.Text + "&" + "password=" + PasswordBx.Text;
UTF8Encoding encoding = new UTF8Encoding();
byte[] byteData = encoding.GetBytes(postData);HttpWebRequest postReq = (HttpWebRequest)WebRequest.Create("https://secure.imvu.com/login/login/");
postReq.Method = "POST";
postReq.CookieContainer = LoginCookie;
postReq.ContentType = "application/x-www-form-urlencoded";
postReq.ContentLength = byteData.Length;using (Stream postreqstream = postReq.GetRequestStream())
{postreqstream.Write(byteData, 0, byteData.Length);
}HttpWebResponse postresponse = (HttpWebResponse)postReq.GetResponse();
LoginCookie.Add(postresponse.Cookies);foreach (Cookie IMVUCookie in postresponse.Cookies)
{if (IMVUCookie != null){if (IMVUCookie.Name == "login_interstitial_seen"){//success}else{//failure}}
}
GeSHi ©The code above is my basic setup for logging into imvu with one of my tools. I do add more to it depending on the program I'm making such as error checking and disabling/enabling controls and changing control texts.


Works like a charm man. i managed to get it working and all. with my limited knowledge of c# atm. but i plan to add more stuff after login. when i can. appreciate the code btw bro. 8)
Tue Jul 14, 2015 5:38 am
User avatar
Master
  • Posts: 78
  • Joined: Feb, 2015
  • Karma: 0
Wow, very interesting i'm gonna try it out as soon as possible this looks very cool hope it still works :badgrin:
Fri Apr 08, 2016 2:05 pm
User avatar
TIM Enthusiast
Legendary Family Member
  • Gender: Female
  • Posts: 702
  • Joined: Sep, 2015
  • Advertisements: 1
  • Karma: 0
Thank you so much DM...thanks for finding time and share this tutorials with us. :bunny:
Mon Oct 02, 2017 4:54 pm
User avatar
  • Posts: 6
  • Joined: Aug, 2017
  • Karma: 10
Well , thank you for coding but it doesn't work because IMVU keeps it more secure.


im getting this error when run the code :

The underlying connection was closed: An unexpected error occurred on a send. :kat_emoji1:


i think we have the issue of using KeepAlive = false/true

Thanks.
OP Mon Oct 02, 2017 5:07 pm
User avatar
Administrator
Legendary Family Member
  • Gender: Male
  • Posts: 6284
  • Joined: Jun, 2010
  • Advertisements: 45
  • Karma: 368
ZedMan wrote:
Well , thank you for coding but it doesn't work because IMVU keeps it more secure.


It works, you just have to be using .Net 4.6 which supports SSL.

@ZedMan
Mon Oct 02, 2017 5:48 pm
User avatar
  • Posts: 6
  • Joined: Aug, 2017
  • Karma: 10
D.M wrote:
It works, you just have to be using .Net 4.6 which supports SSL.@ZedMan


oh right, i will update Framework, thanks DM
OP Tue Oct 03, 2017 5:12 pm
User avatar
Administrator
Legendary Family Member
  • Gender: Male
  • Posts: 6284
  • Joined: Jun, 2010
  • Advertisements: 45
  • Karma: 368
Thanks to
@ZedMan
I was able to update the code in the original post with a much more reliable version.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

Sign up for a new account in our community. It's easy!

REGISTER A NEW ACCOUNT