Kraken API Beispiel

Anfängerfragen zum Programmieren mit PureBasic.
trodat
Beiträge: 2
Registriert: 16.09.2014 13:40

Kraken API Beispiel

Beitrag von trodat »

Ich suche ein lauffähiges Beispiel für die Nutzung der Kraken API:

https://www.kraken.com/help/api

Es würde schon ein Beispiel für die Nutzung von Get ticker information reichen.


Vielen Dank im Voraus.
Benutzeravatar
ts-soft
Beiträge: 22292
Registriert: 08.09.2004 00:57
Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel
Wohnort: Berlin

Re: Kraken API Beispiel

Beitrag von ts-soft »

Das wird wohl etwas aufwendiger :wink:
Erstmal würde ich mir die notwendigen GET und POST aufrufe anschauen, findeste z.B. hier:
http://www.purebasic.fr/english/viewtop ... 13#p410513

Und dann würde ich eher im engl. Forum nochmals Fragen, die Wahrscheinlichkeit, das Dir dort
geholfen werden kann ist doch etwas grösser.

Ich weiß, keine richtige Hilfe aber vielleicht findeste ja so einen Weg.

Gruß
Thomas
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild
trodat
Beiträge: 2
Registriert: 16.09.2014 13:40

Re: Kraken API Beispiel

Beitrag von trodat »

@ts-soft

Das ist doch schon mal ein Anfang, ich bin für jeden Tipp dankbar.
GPI
Beiträge: 1511
Registriert: 29.08.2004 13:18
Kontaktdaten:

Re: Kraken API Beispiel

Beitrag von GPI »

Das dürfte eine HTTPS-Verbindung sein, ohne Windows-API-Aufrufe dürfte das schwer sein.
Der Minecraft-Auth-Prozess brauchte auch sowas, dabei ist das hier rausgekommen:

Code: Alles auswählen

Procedure.s Mojang_server(do$,json$) 
  #INTERNET_OPEN_TYPE_DIRECT = 1 
  #HTTP_ADDREQ_FLAG_ADD = $20000000 
  #HTTP_ADDREQ_FLAG_REPLACE = $80000000 
  #INTERNET_FLAG_SECURE = $800000 
  
  ; 
  ; Type of connection (could be FTP Gopher etc). HTTPS is done as HTTP too. 
  ; 
  #INTERNET_SERVICE_HTTP = 3 
  
  ; 
  ; HTTP port is 80, HTTPS (SSL) port is 443. 
  ; 
  #INTERNET_DEFAULT_HTTPS_PORT = 443  
  ; 
  
  ; Do NOT include http:// or any other protocol indicator here 
  ; 
  host.s = "authserver.mojang.com" 
  
  ; 
  ; Everything after the hostname of the server 
  ; 
  get_url.s = "/"+do$;authenticate" 
  
  ; 
  ; Holds the result from the CGI/page 
  ; 
  result.s = "" 
  
  ; 
  ; All from the wininet DLL 
  ; 
  ; Be sure your Internet Explorer is up to date! 
  ; 
  open_handle = InternetOpen_("MinecraftStarter",#INTERNET_OPEN_TYPE_DIRECT,"","",0) 
  
  connect_handle = InternetConnect_(open_handle,host,#INTERNET_DEFAULT_HTTPS_PORT,"","",#INTERNET_SERVICE_HTTP,0,0) 
  
  request_handle = HttpOpenRequest_(connect_handle,"POST",get_url,"","",0,#INTERNET_FLAG_SECURE,0) 
  
  headers.s = "Content-Type: application/json" +Chr(13)+Chr(10)  
  
  HttpAddRequestHeaders_(request_handle,headers,Len(headers), #HTTP_ADDREQ_FLAG_REPLACE | #HTTP_ADDREQ_FLAG_ADD) 
  
  post_data.s =json$; 
  
  post_data_len = Len(post_data) 
  
  send_handle = HttpSendRequest_(request_handle,"",0,post_data,post_data_len) 
  
  buffer = AllocateMemory(2024)
  
  bytes_read.l 
  
  total_read.l 
  
  total_read = 0 
  
  ; 
  ; Read until we can't read anymore.. 
  ; The string "result" will hold what ever the server pushed at us. 
  ; 
  Repeat 
    
    InternetReadFile_(request_handle,buffer,1024,@bytes_read) 
    result + PeekS(buffer,bytes_read,#PB_Ascii) 
  Until bytes_read=0 
  FreeMemory(buffer)
  ProcedureReturn result
EndProcedure 
Procedure.s Mojang_Auth(name$,password$,clientid$)
  json$="{ "+Chr(34)+"agent"+Chr(34)+": { "+Chr(34)+"name"+Chr(34)+": "+Chr(34)+"Minecraft"+Chr(34)+", "+Chr(34)+"version"+Chr(34)+": 1 }, "
  json$+Chr(34)+"username"+Chr(34)+": "+Chr(34)+name$+Chr(34)+", "
  json$+Chr(34)+"password"+Chr(34)+": "+Chr(34)+password$+Chr(34)
  If clientid$<>""
    json$+", "+Chr(34)+"clientToken"+Chr(34)+": "+Chr(34)+clientid$+Chr(34)
  EndIf  
  json$+" }" 
  ;Debug "send:"+json$
  result$=clear_json(Mojang_server("authenticate",json$))
  ;Debug "auth:"+result$
  ProcedureReturn result$
EndProcedure
Procedure.s Mojang_Refresh(token$,clientid$)
  json$="{ "
  json$+Chr(34)+"accessToken"+Chr(34)+": "+Chr(34)+token$+Chr(34)+", "
  json$+Chr(34)+"clientToken"+Chr(34)+": "+Chr(34)+clientid$+Chr(34)
  json$+" }"
  ;Debug "send:"+json$
  result$=clear_json(Mojang_server("refresh",json$))
  ;Debug "refresh:"+result$
  ProcedureReturn result$
EndProcedure
vielleicht hilfreich für den Anfang.

Dort muss man per Post ein json rüberschicken und bekommt dann eintsprechend antwort. In Header muss da auch ein "Content-Type: application/json" vorhanden sein.

Edit: Das ursprüngliche Teil müsste aus den CodeArchiv kommen:
[http://purearea.net/pb/CodeArchiv/CodeArchiv.html] Die Seite ist nicht hübsch, aber man findet doch einiges.
CodeArchiv Rebirth: Deutsches Forum Github Hilfe ist immer gern gesehen!
Benutzeravatar
bobobo
jaAdmin
Beiträge: 3873
Registriert: 13.09.2004 17:48
Kontaktdaten:

Re: Kraken API Beispiel

Beitrag von bobobo »

schomamit(*) stunnel probiert?


(*) waw
‮pb aktuel 6.2 windoof aktuell und sowas von 10
Ich hab Tinnitus im Auge. Ich seh nur Pfeifen.
Antworten