Christof

You've forgotten that there are still simpletons like me in this
world.......
e.g.
I can't work out why/how there can be a line like  Set Library To
Json/Json.fll
Should this be  Set Library To Json.fll

If there's no GoogleOAuth2.prg, I assume we have to create it.
But I don't know what to place in this prg
loOAuth2 = NewObject("GoogleOAuth2", "GoogleOAuth2.prg")

Please can I appeal to you for more assistance?



On Sat, Dec 1, 2012 at 11:25 PM, Christof Wollenhaupt <
[email protected]> wrote:

> It's not that difficult using the classes I've posted. Here's a sample that
> downloads events from the default calendar:
>
>
> *========================================================================================
> * Read events from a calendar
>
> *========================================================================================
>
>
> *--------------------------------------------------------------------------------------
>  * Manage external dependencies.
>
> *--------------------------------------------------------------------------------------
>  Set Library To Json/Json.fll
> Set Path to Json
> Set Safety off
>
>
> *--------------------------------------------------------------------------------------
> * OAuth 2.0 configuration
>
>
> *--------------------------------------------------------------------------------------
> Local loOAuth2
>  loOAuth2 = NewObject("GoogleOAuth2", "GoogleOAuth2.prg")
> loOAuth2.cClientId = "...insert your own....apps.googleusercontent.com"
>  loOAuth2.cClientSecret = "...insert your own..."
> loOAuth2.cScope = "https://www.googleapis.com/auth/calendar";
>
>
> *--------------------------------------------------------------------------------------
> * Keep the token to avoid repeated authentication
>
>
> *--------------------------------------------------------------------------------------
> If File(loOAuth2.cClientId+".token")
>  loOAuth2.cRefreshToken = FileToStr(loOAuth2.cClientId+".token")
> EndIf
> loOAuth2.GetAccessToken ()
>  If not Empty(loOAuth2.cRefreshToken)
> StrToFile(loOAuth2.cRefreshToken, loOAuth2.cClientId+".token", 0)
>  EndIf
>
>
> *--------------------------------------------------------------------------------------
>  * Load HTTP client
>
> *--------------------------------------------------------------------------------------
>  Local loHttp, lcDocs
> loHttp = NewObject ("CHttpClient", "cHttpClient.prg")
> loHttp.UseSsl()
>  If not loHttp.Connect ("www.googleapis.com")
> Return
>  EndIf
>
>
> *--------------------------------------------------------------------------------------
>  * Get events
>
> *--------------------------------------------------------------------------------------
> Local lcUrl, lcJSON
>  lcUrl = "/calendar/v3/calendars/primary/events"
> loHttp.cHeaders = "" ;
> +"GData-Version: 3.0" + Chr(13)+Chr(10) ;
>  +"Authorization: Bearer " + loOAuth2.GetAccessToken () + Chr(13)+Chr(10)
> lcJSON = loHttp.Get (m.lcUrl)
>
>
> *--------------------------------------------------------------------------------------
> * Convert to an object
>
>
> *--------------------------------------------------------------------------------------
> Local loJson, loEvents
>  loJson = NewObject("Json", "Json/Json.prg")
> loEvents = loJson.Parse (m.lcJSON)
>
>
>
> *--------------------------------------------------------------------------------------
> * Display the first event
>
>
> *--------------------------------------------------------------------------------------
> ? m.loEvents.Items[1].Description
>  ? m.loEvents.Items[1].Start.datetime
>
> For this to run you need to make a small fix to the JSON.PRG. Search for
> all occurrences of lvValue = NULL and place the following code before that
> line:
>
> * FIX: CW, 2012-12Dec-01
> Release lvValue
> Local lvValue
>  * ENDFIX
>
> You also have to register your own API application on
> https://code.google.com/apis/console. The libraries used in this sample
> are
> available on https://code.google.com/apis/console.
>
> Christof
>
>
> --- StripMime Report -- processed MIME parts ---
> multipart/alternative
>   text/plain (text body -- kept)
>   text/html
> ---
>
[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/cag1nny_qog-mqs554q0twg5+uuwlu0yex+ydvjm6sexocxj...@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to