Google Calendar API - 超出未经身份验证的使用的每日限制。继续使用需要注册

时间:2017-08-21 03:57:53

标签: php laravel api calendar

我正在使用Google Calendar APi,当我尝试使用Freebusy时,我收到了一个错误消息。我已经在Stackoverflow中关注了此错误的所有帖子,但它不能与我合作。所以请帮助

public function index()
{
    session_start();
    if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
        $client = new Google_Client();
        $client->setAuthConfig('client_secret.json');
        $client->addScope(Google_Service_Calendar::CALENDAR);

        $client->setAccessType("offline");        // offline access
        $client->setIncludeGrantedScopes(true);   // incremental auth

        $guzzleClient = new \GuzzleHttp\Client(array('curl' => array(CURLOPT_SSL_VERIFYPEER => false)));
        $client->setHttpClient($guzzleClient);

        $cal = new Google_Service_Calendar($client);
        $freebusy_req = new Google_Service_Calendar_FreeBusyRequest();
        $freebusy_req->setTimeMin(date(DateTime::ATOM, strtotime('2017-05-01T08:00:00.000Z')));
        $freebusy_req->setTimeMax(date(DateTime::ATOM, strtotime('2017-05-19T17:00:00.000Z')));
        $freebusy_req->setTimeZone('Europe/London');
        $freebusy_req->setCalendarExpansionMax(10);
        $freebusy_req->setGroupExpansionMax(10);

        $item = new Google_Service_Calendar_FreeBusyRequestItem();
        $item->setId('primary');
        $freebusy_req->setItems(array($item));  
        $query = $cal->freebusy->query($freebusy_req);
        $response_calendar = $query->getCalendars();
        dd($query);
    } else {
        return redirect()->route('oauthCallback');
    }
}

当我尝试dd($ query)时,我收到了这个错误:

 (1/1) Google_Service_Exception

{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}

请帮忙。

0 个答案:

没有答案