HTTPSocket get back URL

When I do a search on maps.google.com with this URL:
https://www.google.de/maps/place/Haifa,+Israel
I got this URL back:
https://www.google.de/maps/place/Haifa,+Israel/@32.7996175,34.9817567,13z/data=!3m1!4b1!4m2!3m1!1s0x151dba4c750de845:0xc35d23982a81529a

How can I get this new created url?

Dim socket1 As New HTTPSocket
Dim data As String = socket1.Get(“https://www.google.de/maps/place/Haifa,+Israel”, 30)
TextArea1.Text = data

Result:

?302 Moved?

302 Moved

?The document has moved?here.????

dim s2 As New HTTPSocket
dim i as new InternetHeaders
i = s2.GetHeaders(“https://www.google.de/maps/place/Haifa,+Israel”, 30)
TextArea1.Text = i.Source

Result:
HTTP/1.0 302 Found??Location: https://www.google.de:443/maps/place/Haifa,+Israel??Cache-Control: private??Content-Type: text/html; charset=UTF-8??P3P: CP=“This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info.”??Date: Mon, 11 Apr 2016 20:51:59 GMT??Server: gws??Content-Length: 247??X-XSS-Protection: 1; mode=block??X-Frame-Options: SAMEORIGIN??Set-Cookie: NID=78=Uce9WL7bexgFpusbAdAbfhGPAm7lxU4UWxHMMRqgs0Yneien1iZ9zulN84t42rS_ZShp88rw4EiZnK_7SOU3uTxwEYgd0M1CRJlgQl1LmH-dvy_O91IDh2_NKM6TLoYw; expires=Tue, 11-Oct-2016 20:51:59 GMT; path=/; domain=.google.de; HttpOnly

You need to handle the Headers: http://documentation.xojo.com/index.php/InternetHeaders

Code 302 is temporary redirect.

I would personally do it with an object in the IDE and handle the HeadersRecieved event:
http://documentation.xojo.com/index.php/HTTPSocket.HeadersReceived

In addition to the 302 it appears you have to handle the cookie.

The new framework Xojo.Net.HttpSocket should handle the 301 and 302 location headers by itself.
(Not sure how this works with the cookie on the 302 though.)

Something more than just a Cookie is needed though. In Safari with cookies disabled the url doesn’t load, but trying it in Xojo with the cookie it still doesn’t work.

edit: here’s a really gross workaround :slight_smile: Add an HTMLViewer, load the url, in docComplete send the href to status and get it there

[code]Sub Action()
HTMLViewer1.LoadURL(“https://www.google.de/maps/place/Haifa,+Israel”)
End Sub

Sub DocumentComplete(URL as String)
me.ExecuteJavaScript(“window.status = window.location.href”)
End Sub

Sub StatusChanged(newStatus as String)
TextArea1.Text = "final url: " + newStatus
End Sub[/code]

Use the google maps api?

https://www.google.com/maps/embed/v1/MODE?key=YOUR_API_KEY&parameters

Where:

{MODE} is one of place, directions, search, view, or streetview.
{YOUR_API_KEY} is your free API key.
parameters include optional parameters, as well as mode-specific parameters.