• Welcome to Theos PowerBasic Museum 2017.

News:

Attachments are only available to registered users.
Please register using your full, real name.

Main Menu

Get gif image WinHttp

Started by Roberto Valois, November 28, 2008, 09:26:44 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Roberto Valois

Hi,

If I type

http://maps.google.com/staticmap?center=40.714728,-73.998672&zoom=12&size=400x400

I get a gif image on my navigator.

I would like to do the same from PB code but get the image on memory.
I have no idea on how to do that.
That's what I'm trying based on José's code:


#Compile Exe
#Dim All

Function PBMain () As Long

   Local oWHttp As Dispatch
   Local vMethod As Variant
   Local vUrl As Variant
   Local vResponseText As Variant
   Local ResultString  As String
   
   ' Create an instance of the HTTP service
   Set oWHttp = New Dispatch In "WinHttp.WinHttpRequest.5.1"  ' <-- change if needed
   If IsFalse IsObject(oWHttp) Then Exit Function

   ' Open an HTTP connection to an HTTP resource
   vMethod = "GET"
   vUrl = "http://maps.google.com/staticmap?center=40.714728,-73.998672&zoom=12&size=400x400"
                             
   Object Call oWHttp.Open(vMethod, vUrl)

   ' Send an HTTP request to the HTTP server
   Object Call oWHttp.Send

   ' Get the response entity body as a string
   Object Get oWHttp.ResponseText To vResponseText

   ResultString = Variant$(vResponseText)

   If IsObject(oWHttp) Then Set oWHttp = Nothing

  Open "Programa.gif" For Binary As #1
  Put$ #1,ResultString
  Close #1

End Function

   
Thank you.
RValois.

José Roca

 
Do not use ResponseText, but ResponseBody. See the last example in this thread: http://www.jose.it-berater.org/smfforum/index.php?topic=2245.0

Roberto Valois

Exactly what I need.
Thank you.
RValois.

BTW, this forum is a mine of gold! Seems that everything that I need to code is here somewhere. :)