perhaps this will help..
Code:
To log the player in, the official launcher sends an HTTPS POST request to:
https://login.minecraft.net
with the postdata:
user=<username>&password=<password>&version=<launcher version>
and a "application/x-www-form-urlencoded" Content-Type header.
The current launcher version is 12, sending a value lower than this will cause the server to return "Old Version", however you can send any large number and it will return as expected. If the login succeeded, it will return 4 ':' delimited values.
1281688214000:deprecated:TkTech:8204407531530365141:
current version of the game files (not the launcher itself). This is a unix timestamp which the launcher compares to the ~/.minecraft/bin/version file.
Previously contained a download ticket for requesting new versions of minecraft.jar from the server. Now contains only "deprecated".
case-correct username.
sessionId - a unique ID for your current session.
this is what im trying to do. my function:
Code:
int login(const char username[16], const char password[32])
{
DWORD ip;
conout("logging on...");
hostent* host = gethostbyname("login.minecraft.net");
if(host == NULL)
{
conout("bad host");
return WSAGetLastError();
}
ip = *(unsigned long*) host->h_addr;
SOCKET loginsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
sockaddr_in login;
login.sin_family = AF_INET;
login.sin_port = htons(80);
login.sin_addr.s_addr = ip;
memset(login.sin_zero, '\0', sizeof(login.sin_zero));
char postreq[8192];
char parameters[100];
sprintf(parameters, "user=%s&password=%s&version=99", username, password);
ZeroMemory(&postreq, sizeof(postreq));
sprintf(postreq, "POST %s HTTP/1.1\r\n", parameters;);
sprintf(postreq, "%sHost: login.minecraft.net\r\n", postreq);
sprintf(postreq, "%sContent-Type: application/x-www-form-urlencoded\r\n", postreq);
sprintf(postreq, "%sContent-Language: en-US\r\n", postreq);
sprintf(postreq, "%sContent-Length: %i\r\n", postreq, strlen(parameters));
sprintf(postreq, "%s\r\n", postreq);
if(connect(loginsock, (sockaddr*)&login, sizeof(login)) == -1)
{
conout("error logging in");
closesocket(loginsock);
WSACleanup();
return WSAGetLastError();
}
if(send(loginsock, postreq, strlen(postreq), 0) == -1)
{
conout("error sending data");
WSACleanup();
closesocket(loginsock);
return WSAGetLastError();
}
conout("login info sent");
char buf[8192];
unsigned size = recv(loginsock, buf, sizeof(buf), 0);
printpacket(buf, size);
return 0;
}