learn to sockets ammar (also made gui optional)
This commit is contained in:
1 parent
135c924f8d
commit
04046d0b47
4 files changed
+136
-50
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import urllib2, urllib
|
||||
|
||||
def loginToMinecraft(username, password):
|
||||
try:
|
||||
url = 'https://login.minecraft.net'
|
||||
header = {'Content-Type' : 'application/x-www-form-urlencoded'}
|
||||
data = {'user' : username,
|
||||
'password' : password,
|
||||
'version' : '13'}
|
||||
data = urllib.urlencode(data)
|
||||
req = urllib2.Request(url, data, header)
|
||||
opener = urllib2.build_opener()
|
||||
response = opener.open(req)
|
||||
response = response.read()
|
||||
print response
|
||||
except urllib2.URLError:
|
||||
toReturn = {'Response' : "Can't connect to minecraft.net"}
|
||||
return toReturn
|
||||
if(response == "Bad login"):
|
||||
toReturn = {'Response' : "Incorrect username/password"}
|
||||
return toReturn
|
||||
response = response.split(":")
|
||||
sessionid = response[3]
|
||||
toReturn = {'Response' : "Good to go!",
|
||||
'Username' : response[2],
|
||||
'SessionID' : sessionid
|
||||
}
|
||||
return toReturn
|
||||
Reference in new issue
Block a user