0

I have to make a get request to a url to download a xml file hourly. I am changing my code over to php.

in the past the code was :

Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.3.0")


oXMLHTTP.Open "GET", "http://api.sportsdatallc.org/golf-t1/leaderboard/pga/2012/tournaments/" & currentidString & "/leaderboard.xml?api_key="given key id", False
oXMLHTTP.Send

If oXMLHTTP.Status = 200 Then
    Set oStream = CreateObject("ADODB.Stream")
    oStream.Open
    oStream.Type = 1
    oStream.Write oXMLHTTP.responseBody
    oStream.SaveToFile "file.xml", 2
    oStream.Close
End If

how can I do this using php? I am confused because of all the extra lines for http.

Prix
  • 19,417
  • 15
  • 73
  • 132
  • possible duplicate of [Save Page As XML](http://stackoverflow.com/a/15308344/342740) – Prix Mar 03 '14 at 00:57

1 Answers1

0

I think you can use:

$xml = file_get_contents("http://api.sportsdatallc.org/golf-t1/leaderboard/pga/2012/tournaments/" & currentidString & "/leaderboard.xml?api_key="given key id");

or you can use the curl library for more advanced requests

http://www.php.net/curl

I hope this help.

Biagiosoft
  • 21
  • 2