Google Calendar Sync 1064 error

gnavarro

Member
Hi,

My config:
Fabrik 3.2
Joomla! 3.3.6 Stable
Template - Protostar
Updated from github
Access to site admin in my Fabrik account

I've implemented the Google Calendar Sync but is retrieving the following error:

1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DISTINCT `fb_sessoes_fisioterapia`.`id` AS __pk_val0 FROM `fb_sessoes_fisioterap' at line 61 SQL=SELECT DISTINCT `fb_sessoes_fisioterapia`.`id` AS `fb_sessoes_fisioterapia___i...

I've followed these installation instructions:
"
IMPORTANT!!!

In order to use the gcalsync plugin, you must install the ZendGdata PHP library.
Down the latest release of the ZendGdata package from:
the Zend website
Extract the content of the download, which includes a lot of examples and docs you don't need.
upload just the ./library/Zend folder to the main Joomla ./libraries folder, so you now have a ...
IMPORTANT!!!

/path/to/your/joomla/libraries/Zend
... which should contains subfolders like Gdata, Http, etc.
That's it. You can now use this plugin.
"

Please advise. Thanks in advance
 
Hi,

Not sure where your error is coming from. But as far as I know this script does no longer work since last november as Google has deprecated its API V2. The Zend Framework on which it runs does not yet implement the V3.
 
Ok... Thanks for your replies!

And is there other friendly way to send Fabrik records/appointments to Google Calendar. If not and that's not asking to much, can you share with me some ready file examples with integrated Google API to do it. I'm not a coding guy just a curios with lack of knowledge... but this is of extremely importance to my project.

Other implementation that I would like to have is my users choosing if they want to send the appointment to their calendars. Is this simply possible or must have a lot of complex hard coding?

I will really appreciate anyone's help on this...
 
What you can do:
- one element (yes/no, radio, one checkbox) for the user to indicate if he wants to send
- a php form plugin checking this element and than doing the link to Google (if this is possible)

The gcalcsync stuff is in plugins\fabrik_cron\gcalsync

BTW: https://joomla.digital-peak.com/products/dpcalendar say they are supporting GoogleCalendar (I didn't try)
 
Thanks for your replies!

Troester,
The dpcalendar have a subscription and I want to avoid that. Probably you're referring to apply some coding using some components from dpcalendar to achive my objectives without the use of subscription but that's to much for me and I would need step by step explanation to achieve it.

Hugh,
For you to rewrite the necessary stuff, is it something to take a lot of time? It would be great for all Fabrik users to have access to the following options:

- Sync Google Calendar (Like you had in the past)
- Plugin or other option for users choose to copy the appointment for their own calendars
- Possibility to the form email plugin send emails with "ics" files attached with the form appointment data

I know... to request is easy :) but this options would boost even more the power of this awesome tool. Thank you for your wonderful job... I'm making web like I've never thought possible for me alone to do it.

waiting for your feedback....
 
I had to find a solution for a customer registration "kind of" medical appointments that they wanted to share on their personal machines.

I've setup a caldav server (actually Baikal) and use php form plugin based on this z_caldav.php lib (https://github.com/fmbiete/Z-Push-contrib/tree/master/include) and its dependencies to synchronize from the fabrik app to the shared iCal on the different Mac.

Based on the Hugh's work for Gcal, I'm also doing some two directions sync. But it's not that much easy....

The SabreDav environment (http://sabre.io/dav/) offers also a library to manipulate VEVENT objects easier.

I believe that a CalDav (and potentially CardDav) synchro script would be a more general alternative than the Gcal one. Because it works with Outlook, Mac iCcal and also Google Calendar which is able to receive DAV sync (but using Oauth2 level login).

The advantage to use you own caldav server to synchronize between machines is mainly confidentiality.

If things are going ok, I'll share them but it's rapidly/poorly coded with French variable names and comments....

Would be better if it's written by some real experts ! :)
 
Thanks for the update.

I've got the gcalsync code out on the slab and looking at it, but it'll take a while to get it re-coded with the Google API, simply because I have so much other stuff to do.

-- hugh
 
It would be grate to integrate Lcollong ideas into Fabrik and turn this functionality even more versatile. But once again nothing I could by myself apply!

So if I'm correct today there are no friendly ways to sync fabrik with gcal.

What about sending list records to Google Spreadsheets? If Fabrik has this possibility I can than mount a Google script to write appointments into a specific calendar.

Until the Google API / CalDav is not implemented this could be a solution, a poor one but it works.

Please tell me... Is it possible to send/sync list records with Google Spreadsheets?
 
Nope, no other way I know of, unless there's a 3rd party utility to do it straight from MySQL.

That's why I wrote the gaclsyn plugin in the first place. I was really hoping Zend would step up and modify their library to use the Google v3 API, so it would "just work", but still no news on that.

-- hugh
 
Hi again,

I've been working with the google api v3 using the server account option and I have it now working to create new calendar events when running the script through the browser.

The first issue I'm facing is when running the script through php form plugin on after process... after form submission the page stays blank and the script doesn't run.

The second issue is that I want to access my form elements through this external php file but I don't know how. The process runs ok with dummy data but when I introduce the line "$test= $formModel->getElementData('fb_sessoes_fisioterapia___id_pac');" the script stops working!

My Questions:
  • How can I access my form field values (my variables) in the bellow piece of php code?
  • How can I run bellow php code through php form plugin on after process ?
  • How can I store in one of my form fields the "id" returned by "$createdEvent->getId();"?

Code:
 <?php
 
 
    session_start();
 
    /************************************************
    Make an API request authenticated with a service
    account.
    ************************************************/
    set_include_path( '../../../../google-api-php-client/src');
 
    require_once 'Google/Client.php';
    require_once 'Google/Service/Calendar.php';
 
    //obviously, insert your own credentials from the service account in the Google Developer's console
    $client_id = '####';
    $service_account_name = '####';
    $key_file_location = '####';
 
    if (!strlen($service_account_name) || !strlen($key_file_location))
        echo missingServiceAccountDetailsWarning();
 
    $client = new Google_Client();
    $client->setApplicationName("Calendario");
 
    if (isset($_SESSION['service_token'])) {
        $client->setAccessToken($_SESSION['service_token']);
    }
 
    $key = file_get_contents($key_file_location);
    $cred = new Google_Auth_AssertionCredentials(
        $service_account_name,
        array('https://www.googleapis.com/auth/calendar'),
        $key
    );
    $client->setAssertionCredentials($cred);
    if($client->getAuth()->isAccessTokenExpired()) {
        $client->getAuth()->refreshTokenWithAssertion($cred);
    }
    $_SESSION['service_token'] = $client->getAccessToken();
 
    $calendarService = new Google_Service_Calendar($client);
    $calendarList = $calendarService->calendarList;
 
    //Set the Event data
 
 
 
    $event = new Google_Service_Calendar_Event();
    $event->setSummary('teste');
    $event->setDescription('descri??o');
 
    $start = new Google_Service_Calendar_EventDateTime();
    $start->setDateTime('2015-02-24T10:00:00.000-07:00');
    $event->setStart($start);
 
    $end = new Google_Service_Calendar_EventDateTime();
    $end->setDateTime('2015-02-24T11:00:00.000-07:00');
    $event->setEnd($end);
 
                //$attendee1 = new Google_Service_Calendar_EventAttendee();
              //  $attendee1->setEmail('gnavarro@fisiolar.pt');
                // ...
                $attendees = array($attendee1,
                                  // ...
                                  );
                $event->attendees = $attendees;
    $createdEvent = $calendarService->events->insert('####', $event);
 
    echo $createdEvent->getId();
 
 
?>

Please advise. Thanks in advance
 
Your form variable will be in $formModel->formData, and/or $formModel->formDataWithTablename, which are both arrays keyed by element name. When running onAfterProcess we have removed the tablename___ prefix in formData, but we keep a copy from before that in formDataWithTableName.

Because when running onAfterProcess, Fabrik has already written out the row data to the database, you'd have to run an update query, using the normal J! database API. Search the forum for things like setQuery, getDbo, etc and you should find some example code.

If you are getting a blank page, set your error reporting in J!'s global settings to maximum, which should give you some information about any errors.

-- hugh
 
Strange! I thought that fabrik website was having problems for the last couple of days.

I've started to get err_connection_timed_out.... meanwhile I've noticed that this appends only when using my wifi connection. Through my mobile using gprs fabrik website works ok!

Do tou know what is generating this impossibly to enter fabrik website when in wifi?
 
It's possible your wifi IP address has been blacklisted on the firewall. When connected through wifi, just type "my ip" in a good search, and let me know it is, I'll check for you.

-- hugh
 
Hugh,

Concerning the blank page I'm getting I've already set the error reporting to maxium and I still have the blank page and no error messages! Am I missing something?

Also, please unlock my IP in the firewall if that's the case ;-)

Thanks
 
Yup, you got blocked for some reason.

Code:
Unblock 176.78.119.71, trying permanent blocks...
 
Removing rule...
DROP  all opt -- in !lo out *  176.78.119.71  -> 0.0.0.0/0  
DROP  all opt -- in * out !lo  0.0.0.0/0  -> 176.78.119.71

Should be good to go now.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top