janboddez / share-on-mastodon

Easily share WordPress posts on Mastodon.
https://jan.boddez.net/wordpress/share-on-mastodon
GNU General Public License v3.0
39 stars 5 forks source link

multiples mastodon sites #19

Closed diehummel closed 2 years ago

diehummel commented 3 years ago

Hi,

more a feature request question. Would be great to be able to post on multiple mastodon site.

Seems currently the plugin can connect to just one instance.

br

janboddez commented 2 years ago

Note to self: I don't think I want to build a GUI that supports this, with multiple (how many?) "Authorize" buttons, etc.

However, it might be possible to eventually allow for a filter callback to splice in multiple hosts/bearer tokens and then loop over all of them. (Mastodon users can define apps/tokens themselves on their instance's settings/applications page, after all.)

$response = wp_remote_post(
  esc_url_raw( $this->options['mastodon_host'] . '/api/v1/statuses' ), // <-- would have to adapt this line
  array(
    'headers'     => array(
      'Authorization' => 'Bearer ' . $this->options['mastodon_access_token'], // <-- would have to adapt this line
    ),
    'data_format' => 'body',
    'body'        => $query_string,
    'timeout'     => 15,
  )
);
janboddez commented 2 years ago

Alternatively, store Mastodon settings in user meta rather than site options.