Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Calendar API --> How can I make the useraccount from which I retrieve Events, variable?
    primarykey
    data
    text
    <p>I'm currently working with the Google Calendar API. I retrieve a list of EVENTS from the user's calendar, but at the moment the account of the user is given in my code. I wan't to make this variable (It should retrieve EVENTS from the account you select).</p> <p>This is my code: </p> <pre><code>&lt;?php require_once 'src/Google_Client.php'; require_once 'src/contrib/Google_CalendarService.php'; $client = new Google_Client(); $client-&gt;setApplicationName('Tryout for Google Calendar'); // Visit https://code.google.com/apis/console?api=plus to generate your // client id, client secret, and to register your redirect uri. $client-&gt;setClientId('myid'); $client-&gt;setClientSecret('mysecret'); $client-&gt;setRedirectUri('http://localhost/gcal/done.php'); $client-&gt;setDeveloperKey('mykey'); $cal = new Google_CalendarService($client); if (isset($_GET['logout'])) { unset($_SESSION['token']); } if (isset($_GET['code'])) { $client-&gt;authenticate($_GET['code']); $_SESSION['token'] = $client-&gt;getAccessToken(); header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); } if (isset($_SESSION['token'])) { $client-&gt;setAccessToken($_SESSION['token']); } if ($client-&gt;getAccessToken()) { $minCheck = date(DATE_ATOM); $eventList = $cal-&gt;events-&gt;listEvents("phpkay@gmail.com", array('singleEvents' =&gt; 'true', 'timeMin' =&gt; $minCheck)); print "&lt;h1&gt;Calendar List&lt;/h1&gt;&lt;pre&gt;" . print_r($eventList, true) . "&lt;/pre&gt;"; $_SESSION['token'] = $client-&gt;getAccessToken(); } else { $authUrl = $client-&gt;createAuthUrl(); print "&lt;a class='login' href='$authUrl'&gt;Connect Me!&lt;/a&gt;"; } ?&gt; </code></pre> <p>This is the part where I set the useraccount, namely: "phpkay@gmail.com"</p> <pre><code>$eventList = $cal-&gt;events-&gt;listEvents("phpkay@gmail.com", array('singleEvents' =&gt; 'true', 'timeMin' =&gt; $minCheck)); </code></pre> <p>How can I retrieve the selected useraccount (the user gets a screen where he can select one of the Google accounts he owns to use for this APP) and use this instead of the set "phpkay@gmail.com"-account?</p> <p>Sorry if my question is unclear, I have no clue how to phrase this in another way.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload