【问题标题】:Google Notification API acknowledgmentGoogle 通知 API 确认
【发布时间】:2014-07-02 12:21:15
【问题描述】:

我在我的服务器上启用了 Google 日历推送通知 API。一切正常,我只缺少最后一组。那就是向 Google 返回确认我已收到消息并且一切都很好。我知道我必须返回 200 的确认,但我不知道如何在 google-api-php-client 中执行此操作。

$client = new Google_Client();
$client->setClientId($client_id);
$client->setDeveloperKey($developer_key);
$client->setClientSecret($client_secret);
$client->setRedirectUri($redirect_uri);
$client->addScope("https://www.googleapis.com/auth/drive");
$client->addScope("https://www.googleapis.com/auth/calendar");
$client->setAccessType('offline');  

$refresh_token = $user['refresh_token'];
$client->refreshToken($refresh_token);  


$service = new Google_Service_Calendar($client);

这是我使用的代码的一部分。

【问题讨论】:

  • 能否请您提供您用于接收推送通知的代码?如果没有它,我可以告诉你的是响应代码 200 是默认响应代码。您可以使用 http_response_code(200) 或使用您的框架提供的任何内容显式设置它,如果您需要但您不需要。 AFAIK 在 google-api-php-client 中没有什么特别之处可以为您接收通知。
  • 如果你用 http_response_code(200) 回答我会给出正确的答案标记。感谢您的帮助!

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


【解决方案1】:

响应代码 200 是默认值。另一种选择是使用 http_response_code(200) 或使用您的框架提供的任何内容显式设置它。 AFAIK google-api-php-client 中没有可以为您接收通知的特殊代码。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-12
    • 2019-10-20
    相关资源
    最近更新 更多