0

I'm using the QR Code generator from google api web page, and trying to download the QR image that results from the data passed.

My problem is that if I put the URL in the browser (have tried with Chrome and IE, and it's working) I get the expected QR Image, I can download with the Save As command in it, and it's ok. But when I use the same URL, and pass it using the GetURL function within powerbuilder, then the QR Code displayed is different from the one I get using the browser directly.

The URL is: (this is an example or the URL that will be passed. The parameter string chl will be different each time it will be called. This is a string that need to have the following format:

?re=XAXX010101000&rr=XAXX010101000&tt=1234567890.123456&id=ad662d33-6934-459c-a128-BDf0393f0f44

being the bold characters that will change. )

https://chart.googleapis.com/chart?cht=qr&chs=480x480&chl=%3Fre%3DXAXX010101000%26rr%3DXAXX010101000%26tt%3D1234567890.123456%26id%3Dad662d33-6934-459c-a128-BDf0393f0f44&choe=UTF-8&chld=M|5

The QR Code resultant when scanned returns only the part "?re=XAXX010101000" as being coded, the remain of the string it appears as not getting "coded". If I change this portion of the string it reflects the change, but the rest of the string is appearing as not received.

The code I'm using to test is: (mle_urlcbb is the control I'm using to store the URL, but in production it will be constructed on the fly)

Integer li_rc
String ls_filename

SetPointer(HourGlass!)
li_rc = iinet_base.GetURL(mle_urlcbb.text, in_irdata)
IF li_rc = 1 THEN
    ls_filename = "C:\TEST\CBB.PNG"
    in_irdata.of_WriteFile(ls_filename, in_irdata.iblob_data)
    MessageBox("Success", "CBB File Successfully downloaded")
ELSE
   MessageBox("Error", "Get CBB Failed")
END IF

I don't know what could be wrong,

Thanks for your answers and/or suggestions.

regards....

Ricardo

RealHowTo
  • 34,977
  • 11
  • 70
  • 85

1 Answers1

0

There is one obvious problem, you are using GetURL and then trying to save the internet result to a file immediately after. This is a common mistake, in fact I made the same mistake the first time I tried using the inet object as I wasn't used to async processing in PowerBuilder.

The InternetResult object acts as a buffer, receiving and caching asynchronous data, as it is returned using the Internet in response to the GetURL and PostURL function calls. The InternetResult object also provides the ability to process this data.

The way you have it coded now MIGHT work some of the time but it will not work all of the time because the load time may not be instantaneous. All you need to do is move the code that writes the result from where it is now to the "internetresult" event of your internetdata nvo.

So.. in the "internetdata" event of your userobject from which you inherited internetresult this is where you grab your resultant page data something like:

// in your non visual that inherited from internetresult put code in the internetdata event to capture the resultant page AFTER it is done loading. :)
string ls_data
ls_data =  String(data,EncodingANSI!)
... then write your file


RETURN 1
Rich Bianco
  • 4,141
  • 3
  • 29
  • 48