Forum Documentation Showcase Pricing Learn more

Webtask/Twitter - upload image as binary/base64

#1

Because of the difficulties with OAUTH 1.0 signing within Bubble, we have a small Node module hosted on webtask.io that does the tweeting for us (just pass the tweet text and the two tokens).

Works very well.

However we now need to post an image to twitter as well (two stage process, upload media, get media id, add id to tweet).

It uses the same node module, and is similarly simple as the tweet publish.

However, I am struggling to convert an image url into binary/base64.

There is not enough persistent storage in webtask, and I am not sure I want to be sending several MBs of image across an external API anyway.

Is this something that could be brought back “in house” by using the new Server Side actions ?

I already have it “working” on Webtask ?

0 Likes

#2

Bringing the whole task back as server side action would be fine, if you paste your code I will have a look if you like.

1 Like

#3

Thanks !

var Twitter = require(‘twitter’);

// Initialize

module.exports = function(context, cb) {
var client = new Twitter({
consumer_key: ‘secret’,
consumer_secret: ‘secret’,
access_token_key: context.query.token,
access_token_secret: context.query.token_secret
});

client.post(‘media:upload’, {media_data: context.query.image}, function(error, response, body) {
if(error) return cb(error);
cb(null, {response});
});
}

It was the “media_data: context.query.image” that I could not get right.

0 Likes

#4

Pretty sure I’ve got this working, just waiting for twitter to approve a developer account so I can get some cress and we should be good.

Unless you have some creds you can PM me?

1 Like

#5

Thanks. Will find some Dev creds for you.

0 Likes