async
(params, auths) => {
}
const oauthSignerUri = auths.twitter.oauth_signer_uri
const twitterParams = ["q", "tweet_mode", "geocode", "lang", "locale", "result_type", "count", "until", "since_id", "max_id", "include_entities"]
const {q, tweet_mode, geocode, lang, locale, result_type, count, until, since_id, max_id, include_entities} = params
p = params
p["tweet_mode"] = tweet_mode ? tweet_mode : "extended"
const config = {
data: '',
method: 'GET',
url: `https://api.twitter.com/1.1/search/tweets.json`,
params: p,
}
const token = {
key: auths.twitter.oauth_access_token,
secret: auths.twitter.oauth_refresh_token,
}
const signConfig = {
token,
oauthSignerUri
}
return (await require("@pipedreamhq/platform").axios(this, config, signConfig))
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, auths) => {
}
let axios = require("axios").default;
let responseArray = [];
for(let i=0; (i<steps.search_twitter.$return_value.statuses.length); i++){
const options = {
method: 'POST',
url: 'https://text-analysis12.p.rapidapi.com/sentiment-analysis/api/v1.1',
headers: {
'content-type': 'application/json',
'x-rapidapi-host': 'text-analysis12.p.rapidapi.com',
'x-rapidapi-key': auths.rapidapi
},
data: {
language: 'english',
text: steps.search_twitter.$return_value.statuses[i].full_text
}
};
try {
let response = await axios(options);
responseArray.push(response.data);
console.log(responseArray);
} catch (error) {
console.error(error.response);
}
}
let formattedArray = [['Tweet #', 'Sentiment' ,'Tweet Body']];
responseArray.forEach((tweet, index) => {
formattedArray.push([index,tweet.sentiment, steps.search_twitter.$return_value.statuses[index].full_text])
})
return formattedArray;
Add multiple rows of data to a Google Sheet
The drive to use. If you are connected with any Google Shared Drives, you can select it here by enabling "Structured Mode".
The Google spreadsheet
Sheet Name
Provide an array of arrays. Each nested array should represent a row, with each element of the nested array representing a cell/column value (e.g., passing [["Foo",1,2],["Bar",3,4]]
will insert two rows of data with three columns each). The most common pattern is to reference an array of arrays exported by a previous step (e.g., {{steps.foo.$return_value}}
). You may also enter or construct a string that will JSON.parse()
to an array of arrays.