Google Calendar API始终发送传递系统通知失败

时间:2016-07-15 10:47:55

标签: php google-api google-calendar-api google-api-php-client

早些时候工作正常,工作几天后

当我使用php代码创建事件时,我开始收到回复邮件说传递系统失败

以下是我用来创建日历活动的代码

public function createEvent($subject = "Unknown Interview Scheduled",
    $attendeesArray = null,
    $startTime = null, $endTime = null,
    $accessToken = null, $refresh_token = null,
    $role = null, $phoneNumber = null,
    $candidateName = null, 
    $applicant_id = null){

    // reformating starttime and end time
    $startTime = (date('Y-m-d\TH:i:s', strtotime($startTime)));
    $endTime = (date('Y-m-d\TH:i:s', strtotime($endTime)));

    $client = new Google_Client();
    $client->setScopes(Google_Service_Calendar::CALENDAR);
    $client->setAuthConfigFile(APP.WEBROOT_DIR.DS.'client_secret_calender.json');
    $var =  new stdClass();
    $var->access_token = $accessToken;
    $var->refresh_token = $refresh_token;
    $var = json_encode($var);
    $client->setAccessToken($var);

    $service = new Google_Service_Calendar($client);
    $event = new Google_Service_Calendar_Event(array(
        'summary' => $subject,
        'description' => 'Interview Scheduled with <a href="https://app.quezx.com/Applicants/view/'.$applicant_id.'">'.$candidateName.'</a> for '.$role. ' position '."\n".' Candidate contact number : '.$phoneNumber ,
        'start' => array(
            'dateTime' => $startTime,
            'timeZone' => 'Asia/Calcutta',
        ),
        'end' => array(
            'dateTime' => $endTime,
            'timeZone' => 'Asia/Calcutta',
        ),
        /*'recurrence' => array(
            'RRULE:FREQ=DAILY;COUNT=2'
        ),*/
        'attendees' => $attendeesArray,
        "guestsCanSeeOtherGuests"=>false,
        'reminders' => array(
            'useDefault' => FALSE,
            'overrides' => array(
                array('method' => 'email', 'minutes' => 24 * 60),
                array('method' => 'popup', 'minutes' => 30),
            ),
        ),
    ));
          $optionArguments = array("sendNotifications"=>true);
          $calendarId = 'primary';
          $event = $service->events->insert($calendarId, $event,$optionArguments);
          pr($event);
}

错误是

  

{       错误:{       错误:       [         {            域:“usageLimits”            原因:“dailyLimitExceededUnreg”,            消息:“超出未经验证的使用的每日限制。继续使用需要注册。”,           extendedHelp:“https://code.google.com/apis/console”          }        ]        代码:403,        消息:“超出未经身份验证的使用的每日限制。继续使用需要注册。”        }   }

1 个答案:

答案 0 :(得分:0)

Handle API Errors中提供的 403:每日限额超出的建议操作之一是遵循Google Calendar API Usage Limits上的建议。除此之外,您还可以尝试下面给出的建议操作403:超出日历使用限制。

  

此外,我发现应用Performance Tips中提供的技术来提高应用程序的性能非常重要和有益。