gpt4 book ai didi

javascript - 使用 Gmail API 搜索参数

转载 作者:行者123 更新时间:2023-11-29 14:38:22 24 4
gpt4 key购买 nike

我正在使用 gmail API 来搜索邮件。我想包括一些搜索参数,但我不知道如何使用多个搜索参数。我想做 older_than 和 -unsubscribe

$(document).ready(function() {
var submitButton = 0;

function randomPicture (){
min = Math.ceil(1);
max = Math.floor(14);
var pictureNumber = Math.floor(Math.random() * (max - min)) + min;
$('.sidetext').css('background-image', 'url(images/pic'+pictureNumber+'.jpg)');
console.log(pictureNumber);
}

$('#submit').click(function(){
randomPicture();
var searchTerm = $('#input-person').val();
listMessages('me', searchTerm, listMessageCallback);
submitButton = submitButton + 1;
$('.quote').remove();

});

function listMessages(userId, query, callback) {
$('#content').css('left', $('sidetext'.offsetLeft));
var getPageOfMessages = function(request, result) {
request.execute(function(resp) {
result = result.concat(resp.messages)
};

var initialRequest = gapi.client.gmail.users.messages.list({
'userId': userId,
'q': query
});

// var Request = gapi.client.gmail.users.messages.list({
// 'q': 'older_than:1y'
// });

getPageOfMessages(initialRequest,[]);
}

function listMessageCallback(result){
console.log(result[0].id);
var messageId = result[0].id;
getMessage('me', messageId, getMessageCallback)

}

function getMessageCallback(result){
console.log(result)
$('#content').html(result.snippet);
$('#content').css('font-size', '20px');
$('#content').css('bottom-margin', '0');
// $('#content').app
}

function getMessage(userId, messageId, callback) {
var request = gapi.client.gmail.users.messages.get({
'userId': userId,
'id': messageId,
'nonce': Math.random()
});
request.execute(callback);
}


})

最佳答案

根据 Searching for Messages :

You can search or filter files using the messages.list and threads.list methods. These methods accept the q parameter which supports the same advanced search syntax as the Gmail web-interface

示例:

GET https://www.googleapis.com/gmail/v1/users/me/messages?q="in:sent after:2014/01/01 before:2014/01/30"

您可以组合 Search operators you can use with Gmail 中所述的多个参数.

Sample:

Messages that match multiple terms
OR or { }

Example: from:amy OR from:david

Example: {from:amy from:david}

关于javascript - 使用 Gmail API 搜索参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42319425/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com