1 回答

TA貢獻(xiàn)1811條經(jīng)驗(yàn) 獲得超6個贊
感謝 04FS 的解決方案('content-type'應(yīng)該是'application/json+protobuf')
如果其他人有興趣:
function list_reminders($httpClient, $num_reminders) {
/*
returns a list of the last num_reminders created reminders, or
None if an error occurred
*/
$body = (object)[
'5' => 1, // boolean field: 0 or 1. 0 doesn't work ˉ\_(ツ)_/ˉ
'6' => $num_reminders, // number of reminders to retrieve
];
$response = $httpClient->request(
'POST',
'https://reminders-pa.clients6.google.com/v1internalOP/reminders/list',
[
'headers' => [ 'content-type' => 'application/json+protobuf' ],
'body' => json_encode($body)
]
);
if ($response->getStatusCode() == 200) {
$content = $response->getBody();
$content_dict = json_decode($content, true);
if (!array_key_exists('1', $content_dict)) {
return [];
}
$reminders_dict_list = $content_dict['1'];
$reminders = [];
foreach($reminders_dict_list as $reminder_dict) {
array_push($reminders, build_reminder($reminder_dict));
}
return $reminders;
}
else {
return null;
}
}
- 1 回答
- 0 關(guān)注
- 110 瀏覽
添加回答
舉報