0
新しいラベルを作成するために公式Gmail PHPライブラリを使用しようとしています。私は標準のOauthを使用してユーザーを認証しています(必要な権限がすべて与えられています)。Gmail PHP APIフィルタの作成問題
しかし、私は次のエラーが表示されます
<b>Fatal error</b>: Uncaught exception 'Google_Service_Exception' with message '{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidArgument",
"message": "Filter doesn't have any actions"
}
],
"code": 400,
"message": "Filter doesn't have any actions"
}
}
次のようにコードは次のとおりです。設定されている
$gmail = new Google_Service_Gmail($google);
$label = new Google_Service_Gmail_Label();
$label->setId('Label_8');
$label2 = new Google_Service_Gmail_Label();
$label2->setId('UNREAD');
$label3 = new Google_Service_Gmail_Label();
$label3->setId('INBOX');
$criteria = new Google_Service_Gmail_FilterCriteria();
$criteria->setFrom('[email protected]');
$action = new Google_Service_Gmail_FilterAction();
$action->setAddLabelIds(array($label));
$action->setRemoveLabelIds(array($label2,$label3));
$filter = new Google_Service_Gmail_Filter();
$filter->setCriteria($criteria);
$filter->setAction($action);
$result = $gmail->users_settings_filters->create('me',$filter);
スコープ:
$google->setScopes(array('https://www.googleapis.com/auth/pubsub','https://mail.google.com','https://www.googleapis.com/auth/gmail.settings.basic'));
を
すべてがプログラムで正常に見えます。私はコードをチェックして、アクションを割り当てています。私は、おそらくライブラリに何か問題があると信じています。どんな助言も役に立ちます。ログを分析することで問題が見つかり
APIエクスプローラーでhttps://developers.google.com/gmail/api/v1/reference/users/settings/filters/create#try-itを実行すると、完全に機能します。 –