Jump to content

Attempting to interface with EVE-Online online Api


Recommended Posts

Hello everyone,

I was wondering if anyone could help me with my script. I'm currently trying to interface and retrieve some XML data from the Eve online API (http://myeve.eve-online.com/api/) but I'm failing at it :P It is giving me no errors or any indication of something going wrong :) but theres just no data return (or perhaps there is no data to return).

here it is:

$test = _EVERetrieveXML("/char/SkillInTraining.xml.aspx","X8gEZAnXnNTg9LxXob4nvYuWw8GDKK7JGsJL7UsDyBwbS2lNbVpqWWJKqlaFhfjW","3511990","1801425305")
ConsoleWrite(String($test))

Func _EVERetrieveXML($path, $apikey = "", $userid = "", $charid = "")
    ConsoleWrite("Creating variables"&@CRLF)
    ; Dim variables.
    Dim $poststring
    Dim $apisite = "api.eve-online.com"
    Dim $csock
    Dim $contents
    
    ConsoleWrite("Constructing post string"&@CRLF)
    ; Constructs Post string.
    If $apikey = Not "" AND $userid = Not "" Then
        $poststring = "userID="&$userid&"&apiKey="&$apikey
        If $charid = Not "" Then
            $poststring &= "&characterID="&$charid
        EndIf
    Else
        $poststring = ""
    EndIf
    ConsoleWrite("Poststing created:"&$poststring&@CRLF)
    
    ConsoleWrite("Opening socket to eve api site"&@CRLF)
    ; Open up socket to api site.
    TCPStartup()
    $csock = TCPConnect(TCPNameToIP($apisite), 80)
    
    ConsoleWrite("Requesting XML page"&@CRLF)
    ; Request XML.
    TCPSend($csock, "POST" & $path & "HTTP/1.0\r\n")
    TCPSend($csock, "Host: " & $apisite & "\r\n")
    TCPSend($csock, "Content-Type: application/x-www-form-urlencoded\r\n")
    TCPSend($csock, "User-Agent: AutoItEveApi\r\n")
    TCPSend($csock, "Content-Length: " & StringLen($poststring) & "\r\n")
    TCPSend($csock, "Connection: close\r\n\r\n")
    If $poststring <> "" Then
        TCPSend($csock, $poststring & "\r\n")
        ConsoleWrite("Poststring send"&@CRLF)
    EndIf
    
    ConsoleWrite("Retrieving contents"&@CRLF)
    ; Retrieve contents.
    While 1
        $contents &= TCPRecv($csock, 2048)
        If @error Then ExitLoop
    WEnd
    ConsoleWrite("Contents recieved"&@CRLF) 
    If $csock <> -1 Then TCPCloseSocket($csock)
    ConsoleWrite("Socket closed"&@CRLF)
    TCPShutdown()
    ConsoleWrite("TCPconnection shut down"&@CRLF)
    
    Return $contents
EndFunc

I based it loosely of this php eve online api that's on the official forums :P

Any help on this matter would be greatly appreciated :D

Greets MMjr

Link to comment
Share on other sites

  • 1 year later...

Hello everyone,

I was wondering if anyone could help me with my script. I'm currently trying to interface and retrieve some XML data from the Eve online API (http://myeve.eve-online.com/api/) but I'm failing at it :) It is giving me no errors or any indication of something going wrong :) but theres just no data return (or perhaps there is no data to return).

here it is:

$test = _EVERetrieveXML("/char/SkillInTraining.xml.aspx","X8gEZAnXnNTg9LxXob4nvYuWw8GDKK7JGsJL7UsDyBwbS2lNbVpqWWJKqlaFhfjW","3511990","1801425305")
ConsoleWrite(String($test))

Func _EVERetrieveXML($path, $apikey = "", $userid = "", $charid = "")
    ConsoleWrite("Creating variables"&@CRLF)
    ; Dim variables.
    Dim $poststring
    Dim $apisite = "api.eve-online.com"
    Dim $csock
    Dim $contents
    
    ConsoleWrite("Constructing post string"&@CRLF)
    ; Constructs Post string.
    If $apikey = Not "" AND $userid = Not "" Then
        $poststring = "userID="&$userid&"&apiKey="&$apikey
        If $charid = Not "" Then
            $poststring &= "&characterID="&$charid
        EndIf
    Else
        $poststring = ""
    EndIf
    ConsoleWrite("Poststing created:"&$poststring&@CRLF)
    
    ConsoleWrite("Opening socket to eve api site"&@CRLF)
    ; Open up socket to api site.
    TCPStartup()
    $csock = TCPConnect(TCPNameToIP($apisite), 80)
    
    ConsoleWrite("Requesting XML page"&@CRLF)
    ; Request XML.
    TCPSend($csock, "POST" & $path & "HTTP/1.0\r\n")
    TCPSend($csock, "Host: " & $apisite & "\r\n")
    TCPSend($csock, "Content-Type: application/x-www-form-urlencoded\r\n")
    TCPSend($csock, "User-Agent: AutoItEveApi\r\n")
    TCPSend($csock, "Content-Length: " & StringLen($poststring) & "\r\n")
    TCPSend($csock, "Connection: close\r\n\r\n")
    If $poststring <> "" Then
        TCPSend($csock, $poststring & "\r\n")
        ConsoleWrite("Poststring send"&@CRLF)
    EndIf
    
    ConsoleWrite("Retrieving contents"&@CRLF)
    ; Retrieve contents.
    While 1
        $contents &= TCPRecv($csock, 2048)
        If @error Then ExitLoop
    WEnd
    ConsoleWrite("Contents recieved"&@CRLF) 
    If $csock <> -1 Then TCPCloseSocket($csock)
    ConsoleWrite("Socket closed"&@CRLF)
    TCPShutdown()
    ConsoleWrite("TCPconnection shut down"&@CRLF)
    
    Return $contents
EndFunc

I based it loosely of this php eve online api that's on the official forums :P

Any help on this matter would be greatly appreciated :idea:

Greets MMjr

I modified this script a bit and added my own API key and I can only get http error 400 return

Link to comment
Share on other sites

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...