Ah yes, I know exactly what you mean @noble.
I found a limitation with the Twitter proxy that Pipedream uses under the hood to send authenticated requests to Twitter.
I needed to upload images to tweets to, so I wrote a component to upload the image with the Twitter Developer App on Pipedream:
import Twit from 'twit';
import fs from 'fs';
export default defineComponent({
props: {
twitter_developer_app: {
type: "app",
app: "twitter_developer_app",
},
altText: {
type: 'string',
label: 'altText',
},
filePath: {
type: 'string',
label: 'Path to file',
description: 'The media file to upload to Twitter from the `/tmp` directory, for example `/tmp/image.png`'
}
},
async run({steps, $}) {
const { api_key, api_secret_key, access_token, access_token_secret } = this.twitter_developer_app.$auth
const T = new Twit({
consumer_key: api_key,
consumer_secret: api_secret_key,
access_token,
access_token_secret,
timeout_ms: 60 * 1000, // optional HTTP request timeout to apply to all requests.
strictSSL: true, // optional - requires SSL certificates to be valid.
})
var b64content = fs.readFileSync(this.filePath, { encoding: 'base64' })
// first we must post the media to Twitter
const { data } = await T.post('media/upload', { media_data: b64content });
// now we can assign alt text to the media, for use by screen readers and
// other text-based presentations and interpreters
const mediaIdStr = data.media_id_string
const meta_params = { media_id: mediaIdStr, alt_text: { text: this.altText } };
const mediaCreateResponse = await T.post('media/metadata/create', meta_params);
$.export('media_id_string', mediaIdStr);
$.export('media_upload_response', mediaUploadResponse);
$.export('media_create_response', mediaCreateResponse);
},
})
Then I was able to use the media_create_response in a later step to actually include the image in a tweet:
module.exports = defineComponent({
props: {
twitter_developer_app: {
type: "app",
app: "twitter_developer_app",
}
},
async run({steps, $}) {
const Twit = require('twit')
const { api_key, api_secret_key, access_token, access_token_secret } = this.twitter_developer_app.$auth
const T = new Twit({
consumer_key: api_key,
consumer_secret: api_secret_key,
access_token,
access_token_secret,
timeout_ms: 60 * 1000, // optional HTTP request timeout to apply to all requests.
strictSSL: true, // optional - requires SSL certificates to be valid.
})
await T.post('statuses/update', {
status: `Good morning Cleveland! 🌆 \n Lake Erie's surface temp is ${steps.convert_lake_erie_to_faren.$return_value}°F.`,
media_ids: steps.upload_image.$return_value.media_id_string
})
},
}
You don’t need to use Javascript in your implementation, you can mix and match between languages on Pipedream.
So you could just use my example media upload code step, then use Tweepy in your second.