Sunday 15 June 2014

php - soap api with betfair -


BetFair is my first time using SOAP API. I have created an XML file and a file that will call that file . I can not understand how I can call it and get one output. I've created the XML file below:

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Soap: Envelope xmlns: Soap = "http://schemas.xmlsoap.org/soap/envelope/" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: xsd = "http : //www.w3.org/2001/XMLSchema "& gt; & Lt; Soaps: Body & gt; & Lt; Login xmlns = "http://www.betfair.com/publicapi/v3/BFGlobalService/" & gt; & Lt; Request & gt; & Lt; LocationId xmlns = "" & gt; 0 & lt; / LocationId & gt; & Lt; Username xmlns = "" & gt; Username & lt; / User & gt; & Lt; Password xmlns = "" & gt; Password & lt; / Password & gt; & Lt; ProductId xmlns = "" & gt; 18 & lt; / ProductId & gt; & Lt; VendorSoftwareId xmlns = "" & gt; 0 & lt; / VendorSoftwareId & gt; & Lt; / Request & gt; & Lt; / Login & gt; & Lt; / Soap: Body & gt; & Lt; / Soap: Envelope & gt;   

Now to call this file I have created a php file to do this. BetFair has given this link for the login API:

  & lt ;? Php $ get_data = file_get_contents ("http://pixelonsell.com/dev2/betfair/login.xml"); $ B = html_entity_decode ($ get_data); $ Data = urlencode ($ b); Print_r ($ data); $ Client = new SOAP client ("https://api.betfair.com/global/v3/BFGlobalService.wsdl"); $ Result = $ client- & gt; LoginReq ($ data); Print_r ($ result); ? & Gt;   

I do not know why this is not working; Can you help me Thank you in advance.

I would like to avoid using a dedicated SOAP library; In my experience they often do not work because of discrepancies in how different server SOAP specifications are implemented. Instead, use a simple HTTP / HTTPS library with the following headers:

  SOAPAction: vase: login content-length: # {myContentLength} content-type: text / XML user-agent : # {MyUserAgent}   

and the following payloads (assuming you're using a free API):

  & lt; SOAP-ENV: Envelope xmlns: SOAP-ENC = "Http://schemas.xmlsoap.org/soap/encoding/" xmlns: SOAP-ENV = "http://schemas.xmlsoap.org/soap/envelope/" xmlns : Xsd = "http: //www.w3 .org / 2001 / XMLSchema" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" & gt; & Lt; Soap-ENV: Body & gt; & Lt; M: Login xmlns: m = "https://api.betfair.com/global/v3/BFGlobalService" & gt; & Lt; M: request & gt; & Lt; Username & gt; # {MyUsername} & lt; / Username & gt; & Lt; Password & gt; # {Mypassword} & lt; / Password & gt; & Lt; LocationId & gt; 0 & lt; / LocationId & gt; & Lt; VendorSoftwareId & gt; 0 & lt; / VendorSoftwareId & gt; & Lt; ProductId & gt; 82 & lt; / ProductId & gt; & Lt; / M: request & gt; & Lt; / M: Login & gt; & Lt; / SOAP-ENV: Body & gt; & Lt; / SOAP-ENV: envelope & gt;   

It seems that you are using the wrong namespace for the login element; Should be '..' No '..'.

Good luck.

No comments:

Post a Comment