How does one get data via a PICKBASIC program using a GOOGLE API .

235 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Neil Pratt

ungelesen,
15.11.2016, 15:20:3815.11.16
an Pick and MultiValue Databases
Not sure if what I'm asking is possible but I run the url below from within a PICKBASIC program (See below) . Problem is it initiates a browser session producing the JSON string below . Question is how do I access this data from the PICK program?

I realize that one doesn't have to get the data this way, but I'm curious as to whether it is possible? . We are also using a C# application to call the API and then create a TXT file which we can then pull into the PICK/D3 database

We use D3 Release Version  9.1.1.AIX64.

======================================================================================================================================
URL


Result.

{
   "dstOffset" : 3600,
   "rawOffset" : -28800,
   "status" : "OK",
   "timeZoneId" : "America/Los_Angeles",
   "timeZoneName" : "Pacific Daylight Time"
}

Q&D PickBasic Program

********************************************************************************************************************************************************************************************************************************************
* Program get.google.timezone

*
*
*** timestamp specifies the desired time as seconds since midnight, January 1, 1970 UTC. The Google Maps Time Zone API uses the timestamp to determine whether or not Daylight Savings should be applied. Times before 1970 can be expressed as negative values.


*LAT  =   "34.067705"  *; PARK LABREA, LOS ANGELES
*LONG = "-118.348552"  *; PARK LABREA, LOS ANGELES

LAT  =   "40.220631"
LONG =  "-77.164572"

*TODAY = DATE() 
TODAY = DATE() - 30

DATE.FROM = ICONV("01/01/1970","D2/")

NO.OF.DAYS = TODAY - DATE.FROM

SECONDS.SINCE.DATE.FROM = (NO.OF.DAYS * 60 * 60) * 24 + TIME()  ;* Number of seconds since midnight, January 1, 1970 UTC  Give or take. Add or subtract seconds for UTC?

TIMESTAMP = SECONDS.SINCE.DATE.FROM

ESC = CHAR(27) ; STX = CHAR(02) ; CR = CHAR(13)

PROG = \https://maps.googleapis.com/maps/api/timezone/json?location=\ : LAT : \,%20\ : LONG : \&timestamp=\ : TIMESTAMP : \ &key=AIzaSyDaX-A44zPKQlEFhkNzYz0zNpxwfI59o6M\

TARGET = ""

PRINT ESC:STX:'<':PROG:' ':TARGET:CR

Nathan Rector

ungelesen,
15.11.2016, 15:45:5815.11.16
an mvd...@googlegroups.com
Neil,

There are 2 ways you can get this information into D3.

1) Using the linux command: CURL
http://www.intl-spectrum.com/resource/671/ISHTTPCLIENT--Using-CURL-and-BASICs-EXECUTE.aspx

2) Use the D3 9 Socket APIs to call the webservice directly.
http://www.intl-spectrum.com/resource/672/ISHTTPCLIENT--D3-91-and-above.aspx

Then you can parse the JSON to get the data:
http://www.intl-spectrum.com/resource/category/69/JSON.aspx


--------------------------------------------
Nathan Rector
International Spectrum, Inc
http://www.intl-spectrum.com
Phone: 720-259-1356

geneb

ungelesen,
15.11.2016, 16:12:3815.11.16
an 'Neil Pratt' via Pick and MultiValue Databases
On Tue, 15 Nov 2016, 'Neil Pratt' via Pick and MultiValue Databases
wrote:

> Not sure if what I'm asking is possible but I run the url below from within
> a PICKBASIC program (See below) . Problem is it initiates a browser session
> producing the JSON string below . Question is how do I access this data
> from the PICK program?
>
> I realize that one doesn't have to get the data this way, but I'm curious
> as to whether it is possible? . We are also using a C# application to call
> the API and then create a TXT file which we can then pull into the PICK/D3
> database
>
Neil, processing data back and forth with D3 is very, VERY, easy using the
MVSP library and C# or VB.Net.

g.

--
Proud owner of F-15C 80-0007
http://www.f15sim.com - The only one of its kind.
http://www.diy-cockpits.org/coll - Go Collimated or Go Home.
Some people collect things for a hobby. Geeks collect hobbies.

ScarletDME - The red hot Data Management Environment
A Multi-Value database for the masses, not the classes.
http://scarlet.deltasoft.com - Get it _today_!

Tony Gravagno

ungelesen,
15.11.2016, 18:21:3615.11.16
an Pick and MultiValue Databases
Another link:
https://github.com/RocketSoftware/multivalue-lab

Neil, there's no need to ever start a question here with "Not sure if what I'm asking is possible but..."
It's always possible - In a public forum you're more likely to have people telling you where to fish, rather than tossing a fish your way. Based on your code sample for AccuTerm, I'm guessing you're OK with that. If you'd like help, folks here including myself are available for consultation and development.

Good Luck!
T

Charlie Noah

ungelesen,
15.11.2016, 18:54:5915.11.16
an mvd...@googlegroups.com
Great answer, Tony - it's always possible!

I'm reminded of the quote "Give a man a fish and he'll eat for a day. Teach him to fish and you'll always know where to find him on the weekend".

Charlie
--
You received this message because you are subscribed to
the "Pick and MultiValue Databases" group.
To post, email to: mvd...@googlegroups.com
To unsubscribe, email to: mvdbms+un...@googlegroups.com
For more options, visit http://groups.google.com/group/mvdbms

Neil Pratt

ungelesen,
21.11.2016, 11:20:2421.11.16
an Pick and MultiValue Databases
Hi Tony,

I disagree with you slightly ..

There are /were some things that are/were impossible. This would have been impossible back in 1985 on the R83 system where I first encountered PICK but I'm being a bit pedantic (nitPICKy?) I know . :). I know what you mean.

Furthermore as I often say to my young PICK protege there are more than one ways to skin a cat...To illustrate my point I have a little program with the following internal subroutines. My little attempt at humor.

*********************************************************************************************************************

186 SKIN.THE.CAT.A: ;* A set number of Attributes with each one a unique type of data.

225 SKIN.THE.CAT.B: ;* Single attribute with subvalues within multivalues.

297 SKIN.THE.CAT.C: ;* Pass a Preformated JSON string back.

*********************************************************************************************************************************************************

BTW: How did you know we use AccuTerm, was it something I said a while back ?

Neil Pratt

ungelesen,
21.11.2016, 11:25:4021.11.16
an Pick and MultiValue Databases
Charlie,

I hear you about the fishing thing but sometimes it's easier to go to a restaurant and just order fish. :).

After looking at the replies to my post , I actually did go fishing, but to be honest I was handed a fishing rod with baited hook and all. All I had to do was cast in and voilla! I caught a fish. Thanks guys.

Neil Pratt

ungelesen,
21.11.2016, 11:42:5921.11.16
an Pick and MultiValue Databases
Hi Nathan,

Thanks for the info. I went with option 1 as we currently use cURL quite extensively for ftp'ing files back and forth.  It worked great and impressed my boss who is also a PICK programmer. He's been trying for a while to get this information from our PCMiler application that we have running on one of our servers here at the office. He's been trying to utilize a PCMiler API .

Your program helped a lot with all the flags and options required by cURL saved me some digging.

I still might look at option 2 later.

Will Johnson

ungelesen,
21.11.2016, 15:13:3021.11.16
an Pick and MultiValue Databases
Well you *are* telling Accuterm to just *throw* the command out there, so that will launch a browser directly.

However there are other ways to *get* the page into a variable in Accuterm scripting and then feed it back down into Pick.

The Esc Stx isn't Accuterm's only  trick.

Glen Batchelor

ungelesen,
21.11.2016, 15:17:0321.11.16
an mvd...@googlegroups.com
I used cURL and my XML parser to handle many SaaS solutions. There are many ways to accomplish it and the only limitation is your experience with the tools you want to use to do it.

--
You received this message because you are subscribed to
the "Pick and MultiValue Databases" group.
To post, email to: mvd...@googlegroups.com
To unsubscribe, email to: mvdbms+unsubscribe@googlegroups.com

Jan Van Schalkwyk

ungelesen,
21.11.2016, 15:20:5621.11.16
an Pick and MultiValue Databases
Hi Neil,

This is how we would do it in UniVerse Basic. This example consumes weather info from Google API


Cheers

Charlie Noah

ungelesen,
22.11.2016, 10:34:5322.11.16
an mvd...@googlegroups.com
Hi Neil,

There's just something about sitting on a lake bank casting a line, whether I actually caught anything at all, that I found very relaxing. At least that was true back when I was physically able to do it. Since my wife hates the smell of fish cooking, I have to order it in a restaurant as you do. We enjoy our trips to Red Lobster very much.

Charlie

Neil Pratt

ungelesen,
22.11.2016, 15:57:2022.11.16
an Pick and MultiValue Databases
Dankie meneer van Scahlkwyk.

Neil Pratt

ungelesen,
22.11.2016, 16:15:5622.11.16
an Pick and MultiValue Databases
Nathan.

IS.HTTPCLIENT calls some subroutines IS.EXECUTE.OS, IS.WRITE.OS and IS.DELETE.OS. Any idea where I could find copies of them?

Somehow I'm losing data when running the cURL command in IS.HTTPCLIENT versus executing the URL directly in a browser.  


The above URL produces the JSON string below but using cURL I get back 2 miles instead of 2,604.  I think it has something to do with the comma

{
   "destination_addresses" : [ "1072 Harrisburg Pike, Carlisle, PA 17013, USA" ],
   "origin_addresses" : [ "401 Hauser Blvd, Los Angeles, CA 90036, USA" ],
   "rows" : [
      {
         "elements" : [
            {
               "distance" : {
                  "text" : "2,604 mi",
                  "value" : 4190188
               },
               "duration" : {
                  "text" : "1 day 14 hours",
                  "value" : 135100
               },
               "status" : "OK"
            }
         ]
      }
   ],
   "status" : "OK"
}

Thanks.

On Tuesday, November 15, 2016 at 3:45:58 PM UTC-5, International Spectrum wrote:

Jan Van Schalkwyk

ungelesen,
23.11.2016, 14:15:5423.11.16
an Pick and MultiValue Databases
Groot plesier Neil, Good to see you have not lost all your roots yet.

Greetings out of Oz :-)
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten