Insertion d'un évènement dans Google Agenda en Php

Réduire
X
 
  • Filtrer
  • Heure
  • Afficher
Tout effacer
nouveaux messages

  • [RÉGLÉ] Insertion d'un évènement dans Google Agenda en Php

    Bonjour

    Insertion d'un évènement dans Google Agenda en Php : mise à jour impossible.

    Avant de développer un composant qui permet une mise à jour de Google Calendar, j'ai souhaité testé la solution en utilisant un simple script Php.
    J'essaie d'insérer un évènement dans Google Agenda à partir d'une application Php.
    J'ai installé Google library sous un répertoire. Vous trouverez en pièces jointes des copies écran :
    - l'écran Google developpers console
    - les paramètres de l'agenda
    J'ai utilisé avec succés dans un script php les fonctions de lecture dans l'agenda. Par contre imopssible d'effectuer une insertion dans cet agenda.
    Pour mettre à jour cet agenda j'utilise le script php suivant :

    <?php
    //INCLUDE THE GOOGLE API PHP CLIENT LIBRARY FOUND HERE
    //https://github.com/google/google-api-php-client
    //DOWNLOAD IT AND PUT IT ON YOUR WEBSERVER IN THE ROOT FOLDER.
    include(__DIR__.'/google-api-php-client-master/src/Google/autoload.php');
    require_once (__DIR__.'/google-api-php-client-master/src/Google/Client.php');
    require_once (__DIR__.'/google-api-php-client-master/src/Google/Service/Calendar.php');
    $client = new Google_Client();
    // $client->setUseObjects(true);
    $client->setApplicationName("mycalendar");
    $client->setClientId("78799027402-584akf302keocfs2a0d1dskv8bt5lj54.apps.googleuserco ntent.com");
    $client->setDeveloperKey('AIzaSyDQ3Dov7U25n0mWKQKn6rC1N2Db OZLpkFE'); //GET AT AT DEVELOPERS.GOOGLE.COM
    //
    $service = new Google_Service_Calendar($client);
    //
    $event = new Google_Service_Calendar_Event();
    $event->setSummary('Event 1');
    $event->setLocation('Somewhere');
    $start = new Google_Service_Calendar_EventDateTime();
    $start->setDateTime('2015-05-26T19:00:00.000+01:00');
    $start->setTimeZone('Europe/Paris');
    $event->setStart($start);
    $end = new Google_Service_Calendar_EventDateTime();
    $end->setDateTime('2015-05-26T19:25:00.000+01:00');
    $end->setTimeZone('Europe/Paris');
    $event->setEnd($end);
    //
    $calendar_id = "paul.xxxxx@gmail.com";
    //
    $new_event = null;
    //
    try {
    $new_event = $service->events->insert($calendar_id, $event);
    //
    $new_event_id = $new_event->getId();
    } catch (Google_ServiceException $e) {
    syslog(LOG_ERR, $e->getMessage());
    }
    ?>


    L'instruction $new_event = $service->events->insert($calendar_id, $event); fait appel à la fonction insert de Calendar.php.
    Ci dessous une copie de cette fonction avec l'ajout d'instructions echo pour afficher certaines variables.


    public function insert($calendarId, Google_Service_Calendar_Event $postBody, $optParams = array())
    {

    $params = array('calendarId' => $calendarId, 'postBody' => $postBody);

    $params = array_merge($params, $optParams);


    echo "Calendar insert00 : $calendarId<br>";


    echo "<br><br><br>";
    print_r($params);


    $Id = $this->call('insert', array($params), "Google_Service_Calendar_Event");

    echo "<br><br>Calendar insert01 : ID : ";

    print_r($Id);

    return $Id;

    // return $this->call('insert', array($params), "Google_Service_Calendar_Event");

    }


    L'instruction $this->call('insert', array($params), "Google_Service_Calendar_Event");
    fait appel à la fonction call de Resource.php.
    L'instruction print_r($Id);

    déclenche l'affichage des données de retour de call('insert'.



    Calendar insert00 : Array ( [calendarId] => paul.terce@gmail.com [postBody] => Google_Service_Calendar_Event Object ( [collection_keyrotected] => recurrence [internal_gapi_mappingsrotected] => Array ( ) [anyoneCanAddSelf] => [attendeesTyperotected] => Google_Service_Calendar_EventAttendee [attendeesDataTyperotected] => array [attendeesOmitted] => [colorId] => [created] => [creatorTyperotected] => Google_Service_Calendar_EventCreator [creatorDataTyperotected] => [description] => [endTyperotected] => Google_Service_Calendar_EventDateTime [endDataTyperotected] => [endTimeUnspecified] => [etag] => [extendedPropertiesTyperotected] => Google_Service_Calendar_EventExtendedProperties [extendedPropertiesDataTyperotected] => [gadgetTyperotected] => Google_Service_Calendar_EventGadget [gadgetDataTyperotected] => [guestsCanInviteOthers] => [guestsCanModify] => [guestsCanSeeOtherGuests] => [hangoutLink] => [htmlLink] => [iCalUID] => [id] => [kind] => [location] => Suresnes [locked] => [organizerTyperotected] => Google_Service_Calendar_EventOrganizer [organizerDataTyperotected] => [originalStartTimeTyperotected] => Google_Service_Calendar_EventDateTime [originalStartTimeDataTyperotected] => [privateCopy] => [recurrence] => [recurringEventId] => [remindersTyperotected] => Google_Service_Calendar_EventReminders [remindersDataTyperotected] => [sequence] => [sourceTyperotected] => Google_Service_Calendar_EventSource [sourceDataTyperotected] => [startTyperotected] => Google_Service_Calendar_EventDateTime [startDataTyperotected] => [status] => [summary] => Insertion Evenement [transparency] => [updated] => [visibility] => [modelDatarotected] => Array ( ) [processedrotected] => Array ( ) [start] => Google_Service_Calendar_EventDateTime Object ( [internal_gapi_mappingsrotected] => Array ( ) [date] => [dateTime] => 2015-05-27T19:00:00.000+01:00 [timeZone] => Europe/Paris [modelDatarotected] => Array ( ) [processedrotected] => Array ( ) ) [end] => Google_Service_Calendar_EventDateTime Object ( [internal_gapi_mappingsrotected] => Array ( ) [date] => [dateTime] => 2015-05-27T19:25:00.000+01:00 [timeZone] => Europe/Paris [modelDatarotected] => Array ( ) [processedrotected] => Array ( ) ) ) )

    Calendar insert01 : ID : Google_Service_Calendar_Event Object ( [collection_keyrotected] => recurrence [internal_gapi_mappingsrotected] => Array ( ) [anyoneCanAddSelf] => [attendeesTyperotected] => Google_Service_Calendar_EventAttendee [attendeesDataTyperotected] => array [attendeesOmitted] => [colorId] => [created] => [creatorTyperotected] => Google_Service_Calendar_EventCreator [creatorDataTyperotected] => [description] => [endTyperotected] => Google_Service_Calendar_EventDateTime [endDataTyperotected] => [endTimeUnspecified] => [etag] => [extendedPropertiesTyperotected] => Google_Service_Calendar_EventExtendedProperties [extendedPropertiesDataTyperotected] => [gadgetTyperotected] => Google_Service_Calendar_EventGadget [gadgetDataTyperotected] => [guestsCanInviteOthers] => [guestsCanModify] => [guestsCanSeeOtherGuests] => [hangoutLink] => [htmlLink] => [iCalUID] => [id] => [kind] => [location] => [locked] => [organizerTyperotected] => Google_Service_Calendar_EventOrganizer [organizerDataTyperotected] => [originalStartTimeTyperotected] => Google_Service_Calendar_EventDateTime [originalStartTimeDataTyperotected] => [privateCopy] => [recurrence] => [recurringEventId] => [remindersTyperotected] => Google_Service_Calendar_EventReminders [remindersDataTyperotected] => [sequence] => [sourceTyperotected] => Google_Service_Calendar_EventSource [sourceDataTyperotected] => [startTyperotected] => Google_Service_Calendar_EventDateTime [startDataTyperotected] => [status] => [summary] => [transparency] => [updated] => [visibility] => [modelDatarotected] => Array ( [error] => Array ( [errors] => Array ( [0] => Array ( [domain] => global [reason] => required [message] => Login Required [locationType] => header [location] => Authorization ) ) [code] => 401 [message] => Login Required ) ) [processedrotected] => Array ( ) )


    Dans l'affichage insert01 je trouve les infos suivantes : [code] => 401 [message] => Login Required
    Pourquoi il est impossible de mettre à jour cet agenda, alors qu'il est possible de lire les évènements. J'ai pourtant indiqué dans les paramètres que l'agenda était public.

    Un gand merci par avance pour l'aide que vous pourrez m'apporter.
    Fichiers joints
    Dernière édition par magnan39 à 26/05/2015, 15h30

Annonce

Réduire
Aucune annonce pour le moment.

Partenaire de l'association

Réduire

Hébergeur Web PlanetHoster
Travaille ...
X