1
Google은 최근 새 버전의 Gmail API를 출시하여 이제는 create filters을 가능하게했습니다.Gmail API를 사용하여 필터 만들기
그러나 설명서가 상당히 제한되어 있으며 제대로 작동하려면 문제가 있습니다. 최신 버전의 PHP client을 사용하고 있습니다. 요청 본문을 작성하는 데 도움이 될 것입니다.
public $gmail;
public function createFilter($userId) {
try {
$filter = new Google_Service_Gmail_Resource_UsersSettingsFilters();
// Here, we should create the request body...
// https://developers.google.com/gmail/api/v1/reference/users/settings/filters#resource
// $filter->setCriteria() ??
$this->gmail->users_settings_filters->create($userId, $filter);
} catch (Exception $e) {
// Logging errors...
}
}
UPDATE (근무 방법)
public $gmail;
public function createFilter($userId) {
try {
$filter = new Google_Service_Gmail_Filter([
'criteria' => [
'from' => '[email protected]'
],
'action' => [
'addLabelIds' => ['STARRED']
]
]);
$this->gmail->users_settings_filters->create($userId, $filter);
} catch (Exception $e) {
// Logging errors...
}
}
고맙습니다. @Brandon. 내 질문에 맞는 해결책을 제시했다. – flo