-1

Google Classroom quickstart.php perfectly worked for me.

Now I need to create web page which prompts user to Login (Oauth) and with those credentials I need to list their Courses.

I tried the sample in Google Classroom questions but all ending up with Google Errors.

Any Working Sample would be highly appreciated.

Thanks in Advance.

1) First Let me know whether the below example is correct

<?php
require __DIR__ . '/src/Google/autoload.php';

/*TODO: get stored $credentials */

$client = new Google_Client();
$client->setClientId('myServiceAccountClientID');
$client->setRedirectUri('REDIRECTURI_PAGE');
$client->setClientSecret('SECRETKEY');
$client->setScopes(array('https://www.googleapis.com/auth/classroom.courses','https://www.googleapis.com/auth/classroom.courses.readonly'));
$client->setAccessToken($credentials);

$service = new Google_Service_Classroom($client);
$results = $service->courses->listCourses();
?>

$credentials is the value of $GET[code] which I got by running Quickstart.php

Raju
  • 1
  • 2
  • Could you be a bit more specific about the sample you tried, and what the errors are? Also try the interactive demo at the bottom of https://developers.google.com/classroom/reference/rest/v1/courses/list – mjs Feb 02 '16 at 14:34
  • Thanks for looking into this. I had added the sample which I tried – Raju Feb 02 '16 at 19:00

1 Answers1

0

The below links was very helpful and I am successful with both Service Account & also with Oauth2.0 which solved my purpose.

Good one for beginners

http://www.daimto.com/google_service_account_php/

http://www.daimto.com/google-oauth2-php/

Raju
  • 1
  • 2