auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params, auths) => {
}
const axios = require("axios")
// Data we need to make the Twitter API request
const oauthSignerUri = auths.twitter.oauth_signer_uri
const token = {
key: auths.twitter.oauth_access_token,
secret: auths.twitter.oauth_refresh_token,
}
const signConfig = {
token,
oauthSignerUri
}
// Download image, base64 encode it, then upload the media to Twitter
const imageResponse = await axios({
url: params.url,
method: "GET",
responseType: "arraybuffer"
})
const media_data = Buffer.from(imageResponse.data, 'binary').toString('base64')
// First, upload the media to Twitter
// https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload
const mediaUploadRequest = {
data: '',
method: 'POST',
url: "https://upload.twitter.com/1.1/media/upload.json",
params: {
media_data
},
}
// We want media_id_string
this.uploadMediaResponse = (await require("@pipedreamhq/platform").axios(this, mediaUploadRequest, signConfig))
this.mediaIdString = this.uploadMediaResponse.media_id_string
async
(params, auths) => {
}
const axios = require('axios')
const oauthSignerUri = auths.twitter.oauth_signer_uri
const {status, in_reply_to_status_id, auto_populate_reply_metadata, exclude_reply_user_ids, attachment_url, media_ids, possibly_sensitive, lat, long, place_id, display_coordinates, trim_user, enable_dmcommands, fail_dmcommands, card_uri} = params
const config = {
url: `https://api.twitter.com/1.1/statuses/update.json`,
method: 'POST',
params,
}
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)