KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Using Google Calendars in 4D Live Window
PRODUCT: 4D Web 2.0 Pack | VERSION: 1.1 | PLATFORM: Mac & Win
Published On: August 1, 2007
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

You can easily view an existing Google Calendar in a 4D Form by using the 4D Live Window plug-in and slightly tweaking the following 4D code. Note that this is a read only view of the calendar, you are not allowed to make or delete events using this simple access method.

The first step is to view your Google Calendar in another web browser, not 4D. Once there, select the Calendar Settings option in the pop-up to the right of the selected calendar. On the web page that shows up select the HTML button for either the Calendar Address or Private Access set of buttons. Either of the buttons will show the basic HTML link that you can use to show your Google Calendar in the 4D Live Window area. The Calendar Address mode means that you must have given public access to the selected calendar, the Private Access means that you give full access to your calendar to whoever has the private-access token (or your code). With either of the HTML buttons you can also select the "configuration tool" link which allows you to customize the look of your calendar with much more detail. The Google Calendar help links have more detailed information on these options.

The following 4D code shows what you need to display your calendar in a 4D Form. Both of these examples use a plug-in area for 4D Live Window named "xLiveWindow". They also need to have the email address and private-access token updated to your particular settings. The required links or HTML code is put into a $html variable so that it can be easily updated with your values.

BASIC LINK

`define the variable used here
C_TEXT($html)

$html:=""
$html:=$html+"http://www.google.com/calendar/embed"
$html:=$html+"?src=yourEmailName%40gmail.com"
$html:=$html+"&pvttk=privateAccessToken"

$webError:=Web_SetURL (xLiveWindow;$html)`load the live HTML page into the 4D Live Window area



MORE CONTROLLED VIEW OF THE CALENDAR

`define the variables used here
C_TEXT($html)
C_BLOB($htmlBLOB)
C_LONGINT($webError)

` build the simple HTML page that will be displayed on your 4D Form using 4D Live Window
` the src parameter is the account name "yourGoogleAccount@gmail.com"
` the pvttk is the Google Calendar assigned access number of this calendar
` see the Google Calendar page that created the HTML for more options and explanations

$html:=""
$html:=$html+"<html>"
$html:=$html+"<body>"
$html:=$html+"<iframe src=\"http://www.google.com/calendar/embed"
$html:=$html+"?src=yourEmailName%40gmail.com"
$html:=$html+"&pvttk=privateAccessToken"
$html:=$html+"&amp;title=4D Tech Tip Calendar"
$html:=$html+"&amp;chrome=NAVIGATION" `change the look: ALL, NAVIGATION, NONE
$html:=$html+"&amp;height=550\""
$html:=$html+" style=border-width:0 width=\"800\" frameborder=\"0\" height=\"550\">"
$html:=$html+"</iframe>"
$html:=$html+"</body>"
$html:=$html+"</html>"

TEXT TO BLOB($html;$htmlBLOB;3) `convert TEXT to BLOB
$webError:=Web_SetContent (xLiveWindow;$htmlBLOB;3) `send the BLOB and display the HTML returned