Last active
September 29, 2018 10:03
-
-
Save ngm/20d98e724f7452912942cc4dc401a761 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add_mastodon_syndication_target($synd_urls, $user_id) | |
{ | |
$masto_target['uid'] = "social_coop"; | |
$masto_target['name'] = "social.coop"; | |
$synd_urls[] = $masto_target; | |
return $synd_urls; | |
} | |
add_filter("micropub_syndicate-to", "add_mastodon_syndication_target", 10, 2); | |
function syndicate_to_mastodon($ID, $syndicate_to) | |
{ | |
$post = get_post($ID); | |
$message = $post->post_content; | |
foreach ($syndicate_to as $syndication_target_uid) { | |
if ($syndication_target_uid === 'social_coop') { | |
$instance = get_option( 'autopostToMastodon-instance' ); | |
$access_token = get_option('autopostToMastodon-token'); | |
$mode = get_option( 'autopostToMastodon-mode', 'public' ); | |
$client = new Client($instance, $access_token); | |
$toot = $client->postStatus($message, $mode); | |
} | |
} | |
} | |
add_filter("micropub_syndication", "syndicate_to_mastodon", 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment