Search code examples
google-apigoogle-classroom

Filter Google Classsroom SDK -> listCoursesAnnouncements where itemDate > Today


I've using the Google Classroom API in PHP.

I can correctly call the API, but can I filter or restrict the API to only look for posts created in the last 25 hours?

eg:


<?php 
    $classroom = new Google_classroom();
    $classroom->setAccessToken($access_token);
    $service = new Google_Service_Classroom($classroom->client);
    $announcements = $service->courses_announcements->listCoursesAnnouncements($course->getId(), [
        'announcementStates' => ['PUBLISHED','DRAFT'],
        'pageSize' => 100000,
        // WHERE updateTime >= date('Y-m-d', strtotime('- 24 hours'));
    ]);

I've googled, and looked at the documentation but can't see a way to filter before the call, Else I need to look through all the posts and filter, but the call takes a long long time.


Solution

  • Answer:

    You are correct the courses.announcements: list endpoint doesn't have a filter pre-request, so you will have to do this posteriorly.

    Feature Request:

    You can however let Google know that this is a feature that is important for access to their APIs, and that you would like to request they implement it.

    Google's Issue Tracker is a place for developers to report issues and make feature requests for their development services, I'd urge you to make a feature request there. The best component to file this under would be the Google Classrom component, with the Feature Request template.