我正在尝试使用 Twitter Stream Api 在 Google 电子表格中搜索一些主题标签。Twitter 搜索 API 没用,因为我也想统计转发次数。我的函数示例在这里。谁能解释一下我必须做什么才能工作得好..
function miniSearch(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sumSheet = ss.getSheetByName("Readme/Settings");
// Authorize to Twitter
var oauthConfig = UrlFetchApp.addOAuthService("twitter");
oauthConfig.setAccessTokenUrl("https://api.twitter.com/oauth/access_token");
oauthConfig.setRequestTokenUrl("https://api.twitter.com/oauth/request_token");
oauthConfig.setAuthorizationUrl("https://api.twitter.com/oauth/authorize");
oauthConfig.setConsumerKey(TWITTER_CONSUMER_KEY);
oauthConfig.setConsumerSecret(TWITTER_CONSUMER_SECRET);
// "twitter" value must match the argument to "addOAuthService" above.
var options = {
'method': 'POST',
"oAuthServiceName" : "twitter",
"oAuthUseToken" : "always"
};
var url = "https://stream.twitter.com/1/statuses/filter.json?track="+"twitterapi";
var response = UrlFetchApp.fetch(url, options);
var tweets = JSON.parse(response.getContentText());
sumSheet.getRange('B8').setValue(tweets[0]["text"]);
}
此函数返回错误代码 504;