View Single Post
Old 13-05-2008, 10:36   #6 (permalink)
Trilobite
Legendary Punter
 
Trilobite's Avatar
 
Join Date: 17 Oct 2006
Posts: 1,459
Awards Showcase
Daily Horse Racing Competition Daily Horse Racing Competition 
Total Awards: 2
Default Re: Betfair Free API

Ok, if anyone is interested in this stuff

Iam getting somewhere now

As far as i can tell the SOAP-ENV:Envelope part stays the same :

HTML Code:
Private Const QUOTE_MARK As String = """"

Private Const sEnvelope = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=" _
& QUOTE_MARK & "http://schemas.xmlsoap.org/soap/envelope/" & QUOTE_MARK _
& " xmlns:SOAP-ENC=" & QUOTE_MARK & "http://schemas.xmlsoap.org/soap/encoding/" & QUOTE_MARK _
& " xmlns:xsi=" & QUOTE_MARK & "http://www.w3.org/2001/XMLSchema-instance" & QUOTE_MARK _
& " xmlns:xsd=" & QUOTE_MARK & "http://www.w3.org/2001/XMLSchema" & QUOTE_MARK & ">" _
& "<SOAP-ENV:Body>"
and the SOAP-ENV:Body part is the xml string you send to the server, which is different for each API function, like the keepAlive.xml


My first working function for the KeepAlive request is:

HTML Code:
Private Function Keep_session_alive(original_key As String) As String

Dim xml_to_send As String, sReply As String


'create the SOAP Envelope    original_key is the latest STRsessionToken

xml_to_send = sEnvelope _
& "<m:keepAlive xmlns:m=" & QUOTE_MARK & "http://www.betfair.com/publicapi/BFService/" & QUOTE_MARK & ">" _
& "<m:request>" _
& "<header>" _
& "<clientStamp>" & GetClientStamp & "</clientStamp>" _
& "<sessionToken>" & original_key & "</sessionToken>" _
& "</header>" _
& "</m:request>" _
& "</m:keepAlive>" _
& "</SOAP-ENV:Body>" _
& "</SOAP-ENV:Envelope>"

' post the request & check the return in sReply variable for errors etc
sReply = MakeSOAPRequest(xml_to_send, "KeepAlive")

Debug.Print sReply

'===============
If InStr(sReply, QUOTE_MARK & "n2:APIErrorEnum" & QUOTE_MARK & ">OK<") > 0 Then ' this indicates was sent OK

   MsgBox "REQUESTING KEEPALIVE WAS OK :-) ", vbInformation


' parse the new session key here and store it in STRsessionToken
STRsessionToken = get_sessionToken(sReply)

'===============
Else

MsgBox "ERROR REQUESTING KEEPALIVE !", vbCritical
End If
'===============

End Function
Trilobite is offline   Reply With Quote