Custom field with button that sends textarea contents

So i’m about to start learning enough Vue to pull this off, but would like to know if i can make a button in the panel that will send the contents of a Textarea through some PHP.

Use case: I’m extending my Twit plugin for K3 to allow Tweeting directly from inside the panel :slight_smile:

Where would I start? Extend the Textarea? or start with a new one?

I would not recommend to extend the textarea since you do not need all the toolbar buttons, autosizing etc.

I would look at copying something like UrlInput and UrlField. And in the Input define a textarea HTML markup.

Thanks @distantnative I was hoping to lock it down to just image and link buttons, since you can tweet both of those, but if those fields are more appropriate, I’ll give them a go. :slight_smile:

techincally with the plugin you can already post to twitter with something like this:

$twitter->post("statuses/update", ["status" => "hello world"]);

I just thought it would be nice to have a field for tweeting about a new blog article, for example.

Oh if you want image and link buttons, that’s something else. I thought you just want a field to enter plain text and hit a button to tweet it out.

Im aiming for it to be as close to Tweeting from the Twitter site as possible, but probably without the polls and geolocation for now. So that means image, video, links, & emojis.

That sounds like quite the effort, adding images, videos through the panel to the backend handing it over to the twitter API. In that case I’d rather start from scratch instead of extending any component.

Actually, i dont think it will be too bad, you can do most of it programmtically already. The plugin registers itself as full blown app with the api and you can already do this programatically (i’ve not tried it but it should work). The plugin is built on top of TwitterOAuth, so anything possible with that should be possible from within the panel.

$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token, $access_token_secret);
$media1 = $connection->upload('media/upload', ['media' => '/path/to/file/kitten1.jpg']);
$media2 = $connection->upload('media/upload', ['media' => '/path/to/file/kitten2.jpg']);
$parameters = [
    'status' => 'Meow Meow Meow',
    'media_ids' => implode(',', [$media1->media_id_string, $media2->media_id_string])
$result = $connection->post('statuses/update', $parameters);

So my thought is Textarea + Files field + button to post it.