Welcome guys to my thread for the new DarkOrbit API by me and FlutterShy (for the autoit version)
Features:
Code Example:
The code of the API:
The C# API:
Regards,
Requi
Features:
Code:
GetResponse(ByVal sUrl As String, ByVal sPost As String) //WebRequest POST GetResponse(ByVal sUrl As String) //WebRequest GET StringBetween(ByRef content As String, ByRef strStart As String, ByRef strEnd As String, Optional ByRef startPos As Integer = 0) //Get a string between 2 strings StringRegExp(ByVal content As String, ByVal regstring As String) Login(ByVal username As String, ByVal password As String, ByVal server As String) //Easy Regular Expressions GetBootys(ByVal content As String) //Get BootyKey count. GetJackpot(ByVal content As String) //Get Jackpot count with €/$ GetMainInfos(ByVal content As String) //Get all infos of the user. Call it with Arrays. 0 = Name, 1 = Full servername, 2 = Premium Status (Yes/No), 3 = Level, 4 = Company, 5 = Map Location, 6 = Registered Date GetUserInfos(ByVal content As String) //Get user infos of the user. Call it wht Arrays. 0 = User ID, 1 = Level, 2 = Honor, 3 = Experience GetHangarInfos(ByVal content As String) //Get infos from hangar. Call it with Arrays. 0 = Actual HP, 1 = Max HP, 2 = Nano Hull, 3, Max Nano hull, 4 = repair voucher, 5 = jump voucher, 7 = Lasercount, 8 = Ammocount, 9 = rocketammocount, 16 = Flaxcount, 17 = iriscount, 14 = dmg/shd ratio, 52 = petname, 53 = petfuel, 54 = pet lvl, 55 = pet hp, 56 = pet fuel, 60 = pet shield/hp ratio GetUID(ByVal content As String) //Get UserID of account GetSID(ByVal content As String) //Get current SID GetCredits(ByVal content As String) //Get current Credits GetUri(ByVal content As String) //Get current Uridium EncodeUsername(ByVal string0 As String) //Encode the username, to login with special chars
Code:
If Login("Requi", "isawesome", "de8") = True Then
Dim src As String = GetResponse("http://" & server + ".darkorbit.bigpoint.com/indexInternal.es?action=internalStart")
GetCredits(src)
GetUri(src)
MsgBox(iCredits)
MsgBox(iUridium)
Else
MsgBox("Username is wrong!!!!!!!!")
End If
Code:
'<C> by Requi (Coding the API)'
'<C> by FlutterShy (Code in Auto(sh)it)'
'<C> by all e*pvp Users, for being our fans ♥'
Option Explicit On
Option Strict On
Imports System.Net
Imports System.IO
Imports System.Text
Imports System.Text.RegularExpressions
Imports System.Runtime.InteropServices
Public Module DarkOrbitAPI
#Region "ToDo List"
'Importing Trapdoor.dll for more features'
'<DllImport("TrapDoor.dll")>'
'Public Function TrapiGetSize(ByVal sessionId As String, ByVal width As Integer, ByVal height As Integer) As Integer'
'End Function'
''
'Code more features'
#End Region
#Region "HTTP"
Public Function GetResponse(ByVal sUrl As String, ByVal sPost As String) As String
Try
Dim nRequest As HttpWebRequest = CType(WebRequest.Create(sUrl), HttpWebRequest)
nRequest.Method = "POST"
nRequest.CookieContainer = cookie
nRequest.ContentType = "application/x-www-form-urlencoded"
nRequest.Proxy = New WebProxy()
Dim nbyteArray() As Byte = Encoding.UTF8.GetBytes(sPost)
nRequest.ContentLength = nbyteArray.Length
Dim nDataStream As Stream = nRequest.GetRequestStream()
nDataStream.Write(nbyteArray, 0, nbyteArray.Length)
nDataStream.Close()
nRequest.KeepAlive = True
nRequest.AllowAutoRedirect = True
nRequest.PreAuthenticate = True
Dim nResponse As HttpWebResponse = CType(nRequest.GetResponse(), HttpWebResponse)
nDataStream = nResponse.GetResponseStream()
Dim nreader As New StreamReader(nDataStream)
Dim nServerResponse As String = nreader.ReadToEnd()
nreader.Close()
nDataStream.Close()
nResponse.Close()
Return nServerResponse
Catch ex As Exception
MsgBox(ex.Message)
Return Nothing
End Try
End Function
Public Function GetResponse(ByVal sUrl As String) As String
Static cookiecontainer As CookieContainer
Static cookiecoll As CookieCollection
Try
If (cookiecoll Is Nothing) Then
cookiecoll = New CookieCollection
End If
If (cookiecontainer Is Nothing) Then
cookiecontainer = New CookieContainer
End If
Dim req As HttpWebRequest = DirectCast(HttpWebRequest.Create(sUrl), HttpWebRequest)
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)"
req.Method = "GET"
req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
req.KeepAlive = True
req.CookieContainer = New CookieContainer()
req.CookieContainer = cookiecontainer
req.CookieContainer.Add(cookiecoll)
req.Proxy = New WebProxy()
Dim response As HttpWebResponse = DirectCast(req.GetResponse(), HttpWebResponse)
Dim sr As StreamReader = New StreamReader(response.GetResponseStream())
Dim html As String = sr.ReadToEnd()
sr.Close()
response.Close()
Return html
Catch ex As Exception
MsgBox(ex.Message)
Return Nothing
End Try
End Function
Public Function StringBetween(ByRef content As String, ByRef strStart As String, ByRef strEnd As String, Optional ByRef startPos As Integer = 0) As String
Try
Dim iPos As Integer, iEnd As Integer, lenStart As Integer = strStart.Length
Dim strResult As String
strResult = String.Empty
iPos = content.IndexOf(strStart, startPos)
iEnd = content.IndexOf(strEnd, iPos + lenStart)
If iPos <> -1 AndAlso iEnd <> -1 Then
strResult = content.Substring(iPos + lenStart, iEnd - (iPos + lenStart))
End If
Return strResult
Catch
Return CStr(False)
End Try
End Function
Public Function StringRegExp(ByVal content As String, ByVal regstring As String) As String
Dim str4 As String = ""
Dim input As String = content
Dim match As Match = Regex.Match(input, regstring, RegexOptions.Multiline)
If (match.Groups.Count = 2) Then
str4 = match.Groups.Item(1).Value
End If
Return str4
End Function
#End Region
#Region "Variables"
Public server As String
Public iGreen As String
Public iRed As String
Public iBlue As String
Public BootyArray(3) As String
Public sJackpot As String
Public sMain As String
Public iInfo As String
Public sHangar As String
Public iUID As String
Public sSID As String
Public sCredits As String
Public sUridium As String
Public cookie As CookieContainer
#End Region
#Region "API"
Public Function Login(ByVal username As String, ByVal password As String, ByVal server As String) As Boolean
Dim sb As StringBuilder = New StringBuilder()
sb.Append("loginForm_default_username=")
sb.Append(EncodeUsername(username))
sb.Append("&loginForm_default_password=")
sb.Append(EncodeUsername(password))
sb.Append("&loginForm_default_login_submit=Login")
Dim sLogged As String = GetResponse("http://www.darkorbit.com/?locale=de&aid=0", sb.ToString)
If sLogged.Contains("serverSelection_ini ini_active") Then
GetResponse("http://" & server & ".darkorbit.bigpoint.com/GameAPI.php?" & StringBetween(sLogged, "http://" & server & ".darkorbit.bigpoint.com/GameAPI.php?", Chr(34) & " onclick=" & Chr(34) & "InstanceSelection.clickedIni(this);" & Chr(34) & ">"))
GetResponse("http://" & server + ".darkorbit.bigpoint.com/indexInternal.es?action=internalDock")
Return True
End If
Return False
End Function
Public Function GetBootys(ByVal content As String) As String()
GetResponse("http://" & server & ".darkorbit.bigpoint.com/indexInternal.es?action=internalDock")
iGreen = StringRegExp(content, "<span title=" & Chr(34) & "(\d) ")
iRed = StringRegExp(content, "<span title=" & Chr(34) & "(\d) ")
iBlue = StringRegExp(content, "<span title=" & Chr(34) & "(\d) ")
BootyArray(0) = iGreen
BootyArray(1) = iRed
BootyArray(2) = iBlue
Return BootyArray
End Function
Public Function GetJackpot(ByVal content As String) As String
sJackpot = StringBetween(content, "<div>", "</div>")
Return sJackpot
End Function
Public Function GetMainInfos(ByVal content As String) As String
GetResponse("http://" & server + ".darkorbit.bigpoint.com/indexInternal.es?action=internalStart")
sMain = StringBetween(content, "class=" & Chr(34) & "userInfo_right" & Chr(34) & ">", "</div><br")
Return sMain
End Function
Public Function GetUserInfos(ByVal content As String) As String
iInfo = StringBetween(content, "<span>", "</span>")
Return iInfo
End Function
Public Function GetHangarInfos(ByVal content As String) As String
GetResponse("http://" & server + ".darkorbit.bigpoint.com/indexInternal.es?action=internalDock")
sHangar = StringBetween(content, "<td class=" & Chr(34) & "values" & Chr(34) & ">", "</td>")
Return sHangar
End Function
Public Function GetUID(ByVal content As String) As String
iUID = StringRegExp(content, "userKeyId : '(.*?)',")
Return iUID
End Function
Public Function GetSID(ByVal content As String) As String
sSID = StringRegExp(content, "var SID='dosid=(.*?)';")
Return sSID
End Function
Public Function GetCredits(ByVal content As String) As String
sCredits = StringBetween(content, "class=" & Chr(34) & "header_money" & Chr(34) & ">", "</div>")
sCredits = sCredits.Replace(" ", "")
Return sCredits
End Function
Public Function GetUri(ByVal content As String) As String
sUridium = StringBetween(content, ";" & Chr(34) & " >", "</a>")
sUridium = sUridium.Trim(CChar(">"))
sUridium = sUridium.Replace(" ", "")
Return sUridium
End Function
Public Function EncodeUsername(ByVal string0 As String) As String
Dim stringdata() As Byte = New UTF8Encoding().GetBytes(string0)
Dim temp As String = ""
For Each b As Byte In stringdata
temp += "%" + BitConverter.ToString(New Byte() {b})
Next
Return temp
End Function
#End Region
End Module
The C# API:
Code:
//<C> by Requi (Coding the API)
//<C> by FlutterShy (Code in Auto(sh)it)
//<C> by all e*pvp Users, for being our fans <3
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;
public static class DarkOrbitAPI
{
#region "ToDo List"
//Importing Trapdoor.dll for more features
//[DllImport("Trapdoor.dll")]
//Public Function TrapiGetSize(ByVal sessionId As String, ByVal width As Integer, ByVal height As Integer) As Integer
//End Function
//
//Code more features
#endregion
#region "Variables"
public static string server;
public static string iGreen;
public static string iRed;
public static string iBlue;
public static string[] BootyArray = new string[3];
public static string sJackpot;
public static string sMain;
public static string iInfo;
public static string sHangar;
public static string iUID;
public static string sSID;
public static string sCredits;
public static string sUridium;
public static CookieContainer cookie;
#endregion
#region "HTTP"
public static string GetResponse(string sUrl, string sPost)
{
try
{
HttpWebRequest nRequest = (HttpWebRequest)WebRequest.Create(sUrl);
nRequest.Method = "POST";
nRequest.CookieContainer = cookie;
nRequest.ContentType = "application/x-www-form-urlencoded";
nRequest.Proxy = new WebProxy();
byte[] nbyteArray = Encoding.UTF8.GetBytes(sPost);
nRequest.ContentLength = nbyteArray.Length;
Stream nDataStream = nRequest.GetRequestStream();
nDataStream.Write(nbyteArray, 0, nbyteArray.Length);
nDataStream.Close();
nRequest.KeepAlive = true;
nRequest.AllowAutoRedirect = true;
nRequest.PreAuthenticate = true;
HttpWebResponse nResponse = (HttpWebResponse)nRequest.GetResponse();
nDataStream = nResponse.GetResponseStream();
StreamReader nreader = new StreamReader(nDataStream);
string nServerResponse = nreader.ReadToEnd();
nreader.Close();
nDataStream.Close();
nResponse.Close();
return nServerResponse;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return null;
}
}
static CookieContainer static_GetResponse_cookiecontainer;
static CookieCollection static_GetResponse_cookiecoll;
public static string GetResponse(string sUrl)
{
try
{
if ((static_GetResponse_cookiecoll == null))
{
static_GetResponse_cookiecoll = new CookieCollection();
}
if ((static_GetResponse_cookiecontainer == null))
{
static_GetResponse_cookiecontainer = new CookieContainer();
}
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(sUrl);
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)";
req.Method = "GET";
req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
req.KeepAlive = true;
req.CookieContainer = new CookieContainer();
req.CookieContainer = static_GetResponse_cookiecontainer;
req.CookieContainer.Add(static_GetResponse_cookiecoll);
req.Proxy = new WebProxy();
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream());
string html = sr.ReadToEnd();
sr.Close();
response.Close();
return html;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return null;
}
}
public static string StringBetween(string content, string strStart, string strEnd)
{
try
{
int iPos = 0;
int startPos = 0;
int iEnd = 0;
int lenStart = strStart.Length;
string strResult = null;
strResult = string.Empty;
iPos = content.IndexOf(strStart, startPos);
iEnd = content.IndexOf(strEnd, iPos + lenStart);
if (iPos != -1 && iEnd != -1)
{
strResult = content.Substring(iPos + lenStart, iEnd - (iPos + lenStart));
}
return strResult;
}
catch
{
return Convert.ToString(false);
}
}
public static string StringRegExp(string content, string regstring)
{
string str4 = "";
string input = content;
Match match = Regex.Match(input, regstring, RegexOptions.Multiline);
if ((match.Groups.Count == 2))
{
str4 = match.Groups[1].Value;
}
return str4;
}
#endregion
#region "API"
public static bool Login(string username, string password, string server)
{
StringBuilder sb = new StringBuilder();
sb.Append("loginForm_default_username=");
sb.Append(EncodeUsername(username));
sb.Append("&loginForm_default_password=");
sb.Append(EncodeUsername(password));
sb.Append("&loginForm_default_login_submit=Login");
string sLogged = GetResponse("http://www.darkorbit.com/?locale=de&aid=0", sb.ToString());
if (sLogged.Contains("serverSelection_ini ini_active"))
{
GetResponse("http://" + server + ".darkorbit.bigpoint.com/GameAPI.php?" + StringBetween(sLogged, "http://" + server + ".darkorbit.bigpoint.com/GameAPI.php?", ((char)34).ToString() + " onclick=" + ((char)34).ToString() + "InstanceSelection.clickedIni(this);" + ((char)34).ToString() + ">"));
GetResponse("http://" + server + ".darkorbit.bigpoint.com/indexInternal.es?action=internalDock");
return true;
}
return false;
}
public static string[] GetBootys(string content)
{
GetResponse("http://" + server + ".darkorbit.bigpoint.com/indexInternal.es?action=internalDock");
iGreen = StringRegExp(content, "<span title=" + ((char)34).ToString() + "(\\d) ");
iRed = StringRegExp(content, "<span title=" + ((char)34).ToString() + "(\\d) ");
iBlue = StringRegExp(content, "<span title=" + ((char)34).ToString() + "(\\d) ");
BootyArray[0] = iGreen;
BootyArray[1] = iRed;
BootyArray[2] = iBlue;
return BootyArray;
}
public static string GetJackpot(string content)
{
sJackpot = StringBetween(content, "<div>", "</div>");
return sJackpot;
}
public static string GetMainInfos(string content)
{
GetResponse("http://" + server + ".darkorbit.bigpoint.com/indexInternal.es?action=internalStart");
sMain = StringBetween(content, "class=" + ((char)34).ToString() + "userInfo_right" + ((char)34).ToString() + ">", "</div><br");
return sMain;
}
public static string GetUserInfos(string content)
{
iInfo = StringBetween(content, "<span>", "</span>");
return iInfo;
}
public static string GetHangarInfos(string content)
{
GetResponse("http://" + server + ".darkorbit.bigpoint.com/indexInternal.es?action=internalDock");
sHangar = StringBetween(content, "<td class=" + ((char)34).ToString() + "values" + ((char)34).ToString() + ">", "</td>");
return sHangar;
}
public static string GetUID(string content)
{
iUID = StringRegExp(content, "userKeyId : '(.*?)',");
return iUID;
}
public static string GetSID(string content)
{
sSID = StringRegExp(content, "var SID='dosid=(.*?)';");
return sSID;
}
public static string GetCredits(string content)
{
sCredits = StringBetween(content, "class=" + ((char)34).ToString() + "header_money" + ((char)34).ToString() + ">", "</div>");
sCredits = sCredits.Replace(" ", "");
return sCredits;
}
public static string GetUri(string content)
{
sUridium = StringBetween(content, ";" + ((char)34).ToString() + " >", "</a>");
sUridium = sUridium.Trim(Convert.ToChar(">"));
sUridium = sUridium.Replace(" ", "");
return sUridium;
}
public static string EncodeUsername(string string0)
{
byte[] stringdata = new UTF8Encoding().GetBytes(string0);
string temp = "";
foreach (byte b in stringdata)
{
temp += "%" + BitConverter.ToString(new byte[] { b });
}
return temp;
}
#endregion
}
Code:
if (DarkOrbitAPI.Login("Requi", "isawesome", "de8")) == true
{
string src = DarkOrbitAPI.GetResponse("http://" & server + ".darkorbit.bigpoint.com/indexInternal.es?action=internalStart");
DarkOrbitAPI.GetCredits(src);
DarkOrbitAPI.GetUri(src);
MessageBox.Show(iCredits);
MessageBox.Show(iUridium);
}
else
{
MessageBox.Show("Username is wrong!!!!!!!!");
}
Regards,
Requi