Hi,
I want to use the GoogleMapsDirections API:
For example like this:
http://maps.googleapis.com/maps/api/distancematrix/xml?origins=Reitbahnstra%C3%9Fe%2042%2009111%20Chemnitz+DE&destinations=Mittweidaer%20Stra%C3%9Fe%2036%2009131%20chemnitz+DE&mode=driving&language=de-DE&sensor=false
Now I thougt I use the HTTPSocket to receif the contents:
Dim socket1 As New HTTPSocket
Dim data As String = socket1.Get("GoogleMaps-API-String", 30)
msgbox data
But I alway get an empty result.
If I paste the links into the webbrowser it works.
What is my problem?
Thanks for the help!
Check the HTTPStatusCode. Maybe there is a redirect (status code 3xx)
It also may be that they require the user-agent header to be set. Remember, HTTPSocket is not a browser. It’s just a raw socket for retrieving data.
Are you quoting your string name?
With this:
Dim y as string
y="http://maps.googleapis.com/maps/api/distancematrix/xml?origins=Reitbahnstra%C3%9Fe%2042%2009111%20Chemnitz+DE&destinations=Mittweidaer%20Stra%C3%9Fe%2036%2009131%20chemnitz+DE&mode=driving&language=de-DE&sensor=false"
Dim socket1 As New HTTPSocket
Dim data As String = socket1.Get(y, 30)
Textarea1.text= data
Under RB I get back
<?xml version="1.0" encoding="UTF-8"?>
<DistanceMatrixResponse>
<status>OK</status>
<origin_address>Reitbahnstraße 42, 09111 Chemnitz, Deutschland</origin_address>
<destination_address>Mittweidaer Straße 36, 09131 Chemnitz, Deutschland</destination_address>
<row>
<element>
<status>OK</status>
<duration>
<value>856</value>
<text>14 Minuten</text>
</duration>
<distance>
<value>7317</value>
<text>7,3 km</text>
</distance>
</element>
</row>
</DistanceMatrixResponse>