I'm trying to get the tasklist ID via API, but I got the wrong ID. when I tested getting tasklists in Google APIs Explorer - I got correctly ID
here is my code(I took it from the documentation):
use Google\Service\Tasks;
function getClient() {
$client = new Google_Client();
$client->setAuthConfig('key.json');
$client->setApplicationName('name');
$client->setScopes('https://www.googleapis.com/auth/tasks');
return $client;
}
// Get the API client and construct the service object.
$client = getClient();
$service = new Tasks($client);
// Print the first 10 task lists.
try {
$optParams = array(
'maxResults' => 10,
);
$results = $service->tasklists->listTasklists($optParams);
var_dump($results->getItems());
if (count($results->getItems()) == 0) {
print "No task lists found.\n";
} else {
print "Task lists:\n";
foreach ($results->getItems() as $tasklist) {
printf("%s (%s)\n", $tasklist->getTitle(), $tasklist->getId());
}
}
} catch (Exception $e) {
// TODO(developer) - handle error appropriately
echo 'Message: ' . $e->getMessage();
}