Не удается использовать пакетный запрос в Google Classroom API

Я использую Google SDK PHP для выполнения запроса получения пакета, чтобы получить список курсов в Google Classroom. Мой скрипт использует служебную учетную запись для доступа к данным sguite без подтверждения пользователя. Если я отключаю пакетный режим, он работает нормально, но при включении пакетного режима возникает ошибка
Вот мой код

<?php
namespace app\Libs;
use Google_Client;
use Google_Service_Classroom;class ClassRoom

{private $api, $adminEmail, $client;

const SCOPES = ['https://www.googleapis.com/auth/classroom.course-work.readonly','https://www.googleapis.com/auth/classroom.courses','https://www.googleapis.com/auth/classroom.courses.readonly','https://www.googleapis.com/auth/classroom.coursework.me','https://www.googleapis.com/auth/classroom.coursework.me.readonly','https://www.googleapis.com/auth/classroom.coursework.students','https://www.googleapis.com/auth/classroom.coursework.students.readonly','https://www.googleapis.com/auth/classroom.profile.emails','https://www.googleapis.com/auth/classroom.profile.photos','https://www.googleapis.com/auth/classroom.rosters','https://www.googleapis.com/auth/classroom.rosters.readonly','https://www.googleapis.com/auth/classroom.student-submissions.me.readonly','https://www.googleapis.com/auth/classroom.student-submissions.students.readonly','https://www.googleapis.com/auth/classroom.guardianlinks.students'];function __construct($adminEmail)
{
$this->adminEmail = $adminEmail;
$client = new Google_Client();
$client->setAuthConfig('config.json');
$client->setScopes(self::SCOPES);
$client->setSubject($adminEmail);
$this->api = new Google_Service_Classroom($client);
}function addClasses()
{
$client = $this->api->getClient();
$client->setUseBatch(true);
$batch = new Google_Http_Batch($client);
$ownerId = '[email protected]';
$x1 = new Google_Service_Classroom_Course(['name'=>'Math']);
$x1->setOwnerId($ownerId);
$r1 = $this->api->courses->create($x1);
$batch->add($r1, "a");

$x2 = new Google_Service_Classroom_Course(['name'=>'Geography']);
$x2->setOwnerId($ownerId);
$r2 = $this->api->courses->create($x2);
$batch->add($r2, "b");

$results = $batch->execute();
var_dump($results);

$client->setUseBatch(false);
}
}

?>

Когда я использую пакетный запрос с Google Calendar API, все в порядке. Но с Classroom API, я получил результаты, которые

    object(Google_Service_Exception)#209 (8) {
["errors":protected]=>
NULL
["message":protected]=>
string(9) "Not Found"["string":"Exception":private]=>
string(0) ""["code":protected]=>
int(404)
["file":protected]=>
string(71) "/home/ubuntu/workspace/vendor/google/apiclient/src/Google/Http/REST.php"["line":protected]=>
int(118)
["trace":"Exception":private]=>
array(51) {
[0]=>
array(6) {
["file"]=>
string(72) "/home/ubuntu/workspace/vendor/google/apiclient/src/Google/Http/Batch.php"["line"]=>
int(172)
["function"]=>
string(18) "decodeHttpResponse"["class"]=>
string(16) "Google_Http_REST"["type"]=>
string(2) "::"["args"]=>
array(2) {
[0]=>
object(GuzzleHttp\Psr7\Response)#226 (6) {
["reasonPhrase":"GuzzleHttp\Psr7\Response":private]=>
string(9) "Not Found"["statusCode":"GuzzleHttp\Psr7\Response":private]=>
int(404)
["headers":"GuzzleHttp\Psr7\Response":private]=>
array(5) {
["content-type"]=>
array(1) {
[0]=>
string(24) "text/html; charset=UTF-8"}
["date"]=>
array(1) {
[0]=>
string(29) "Fri, 24 Feb 2017 03:18:58 GMT"}
["expires"]=>
array(1) {
[0]=>
string(29) "Fri, 24 Feb 2017 03:18:58 GMT"}
["cache-control"]=>
array(1) {
[0]=>
string(18) "private, max-age=0"}
["content-length"]=>
array(1) {
[0]=>
string(1) "9"}
}
["headerNames":"GuzzleHttp\Psr7\Response":private]=>
array(5) {
["content-type"]=>
string(12) "content-type"["date"]=>
string(4) "date"["expires"]=>
string(7) "expires"["cache-control"]=>
string(13) "cache-control"["content-length"]=>
string(14) "content-length"}
["protocol":"GuzzleHttp\Psr7\Response":private]=>
string(3) "1.1"["stream":"GuzzleHttp\Psr7\Response":private]=>
object(GuzzleHttp\Psr7\Stream)#195 (7) {
["stream":"GuzzleHttp\Psr7\Stream":private]=>
resource(21) of type (stream)
["size":"GuzzleHttp\Psr7\Stream":private]=>
NULL
["seekable":"GuzzleHttp\Psr7\Stream":private]=>
bool(true)
["readable":"GuzzleHttp\Psr7\Stream":private]=>
bool(true)
["writable":"GuzzleHttp\Psr7\Stream":private]=>
bool(true)
["uri":"GuzzleHttp\Psr7\Stream":private]=>
string(10) "php://temp"["customMetadata":"GuzzleHttp\Psr7\Stream":private]=>
array(0) {
}
}
}

.....

Что я должен делать 🙁

1

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]