NetTalk Central

Author Topic: NetWebClient, calling a procedure to retrieve data from Google Data API's  (Read 2163 times)

Rene Simons

  • Hero Member
  • *****
  • Posts: 649
    • View Profile
Hi,
I am retrieving data using the Google Data Api.
These api's return json-formatted data sets.
The maximum list size I can receive is 50 items per call.
When there are more items available, the URL used to retrieve the data must be extended  with '&nextPage=<NextPageToken>.
And the URL has to be called again to retrieve the next (max.) 50 items. And again and again etc.

This calls for a loop, I would guess.
The NetWebClient requires that after calling the URL, further processing is executed in the .PageReceived or ErrorTrap methods, depending on how succesful the .fetch method was.
My understanding is that the .fetch method does not wait until the execution of the .PageReceived has finished before it moves on.

What I would like to know.
How can I process the received data in the .PageReceived method and return the value in order to be able to know to retrieve the next batch of data? In other words: How can I simolate a loop, based on info from the retrieved json-data?

Cheers,
René Simons


 
Rene Simons
NT14.14

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11155
    • View Profile
>> This calls for a loop, I would guess.

not really a loop, but keep reading...

>> The NetWebClient requires that after calling the URL, further processing is executed in the .PageReceived or ErrorTrap methods,
depending on how succesful the .fetch method was.

Correct. In computer terms communications take _ages_. So you do the FETCH, and then it carries on work through the ACCEPT command, accepting events and so on. It basically does more work than you ever did in primary school, and eventually after the icecaps have melted the reply arrives (via an Event) and is then fed into the PageReceived method.

>> My understanding is that the .fetch method does not wait until the execution of the .PageReceived has finished before it moves on.

correct, the code that comes after the FETCH executes (long) before the FETCH has completed. (Actually it completes before it's really even got started...)

>> How can I process the received data in the .PageReceived method and return the value in order to be able to know to retrieve the next batch of data?

How you process the incoming 50 records depends a bit on the format it's coming in as. (I'm guessing JSON so you could use jFiles to process it there.) When that's all done you can just call FETCH again....

>> In other words: How can I simulate a loop, based on info from the retrieved json-data?

In PageReceived you handle the incoming data, and (if you need to) do another FETCH.

cheers
Bruce


Rene Simons

  • Hero Member
  • *****
  • Posts: 649
    • View Profile
That simple huh? Thanks  ;D
Rene Simons
NT14.14