Why The Skies Are Blue

There’s a mass exodus from Twitter – (laterly known as “X”) – and for many good reasons.

I have now joined that exodus.

The owner of Twitter – (and Tesla, SpaceX, and others) – has destroyed a platform that became the background radiation of the internet. People went there to interact, to check out what was going on – it was often the best place for breaking news.

While it is still reasonably good at those things, the level of discourse – (frankly) – has turned to shit.

When he took over, the owner promised things would be better:

  • He promised to get rid of the bot and spam accounts or “die trying“.
    • Frankly, he should have died many times over by now if he were sticking to his word – I’ve not been keeping count, but I would guess 450 of the last 500 accounts that have followed me have been bots or porn spam. I’ve blocked most of them as they’ve come in, but there’s only many you can block before you give up.
  • He promised Twitter would be a bastion of “free speech“.
    • Well, only if it his free speech – not ours. There is a clear bias that downplays views that he doesn’t agree with, and promotes that which he does. It’s not so blatant that such tweets are “quietly disappeared“, but the algorithm does not actively promote them when tweets that suit his world view are promoted. The last time I looked at the pointless “For You” tab, 13 of the first 15 tweets were from the man himself.
  • Moderation has gone to hell, with the trust and safety team decimated.
    • I have reported many highly offensive tweets over my 17 years on Twitter, and previous to the change of ownership, most if not all were dealt with appropriately. Now, almost none are dealt with – with “no violation found” responses common, yet while seemingly in breach of the published rules. I am guessing this is likely to line up with the “free speech” policy.
  • And of course, the politics.
    • The owner’s current politics – and propensity to attack others who disagree with his world view – is just rotten. Don’t get me wrong, like everyone he is allowed his political views, but to actively use the platform to discourage, attack and belittle people with different views once again goes against the free speech “policy”. He is a hypocrite of the highest order.
  • Legal changes.

Enough.

The skies are much clearer and bluer in other corners of the internet. I will keep my Twitter account open – (such that I can protect my 17 year old Twitter handle from misuse – and it’s a handle I have used all over the internet for more than 30 years) – but I will no longer actively use it.

My automatically posted news links will still appear there – (for the sake of reach) – but other than that, I’m not going there. Don’t expect interaction from me there, and the account is in private mode now anyway.

Twitter can go to hell.

But – to be fair – I think it already has.

First Use Of Mastodon API

With the growing exodus of people to various Mastodon instances in the wake of the purchase of Twitter by serial boofhead Elon Musk, people will be starting to look for integration tools to start exploiting the Mastodon API.

My first dabble into it has been to update my personal management console to post my links to my chosen Mastodon instance, as well as Twitter for the time being at least.

Here’s a simple PHP function I wrote this morning that allows for simple toots to be posted via scripts or other tools you might like to do this for.

function mastodon_toot ($user_token,$mastodon_url,$toot_content)
{
  $post_data = Array("status"=>"".@str_replace("\'","▒~V~R~V~R~@~Y",$toot_content)."","language"=>"eng","visibility"=>"public");
  $post_headers = ['Authorization: Bearer '.$user_token.''];
  $curl_handle = @curl_init();
  curl_setopt($curl_handle,CURLOPT_URL,"https://".$mastodon_url."/api/v1/statuses");
  curl_setopt($curl_handle,CURLOPT_POST,1);
  curl_setopt($curl_handle,CURLOPT_POSTFIELDS,$post_data);
  curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,TRUE);
  curl_setopt($curl_handle,CURLOPT_HTTPHEADER,$post_headers);
  $curl_execute = @json_decode(@curl_exec($curl_handle));
  $http_code = "".@curl_getinfo($curl_handle,CURLINFO_HTTP_CODE);
  @curl_close($curl_handle);
  if ($http_code <> "200") {
    $result_code = "HTP";
    $result_message = "cURL returned HTTP code '".$http_code."' when attempting post to the '".$mastodon_url."' instance!";
    $result_data = NULL;
  } else {
    $result_code = "AOK";
    $result_message = "The flilm is okie dokie!";
    $result_data = Array("api_response"=>$curl_execute,"toot_id"=>"".$curl_execute->id."");
  }
  return(Array("result_code"=>$result_code,"result_message"=>$result_message,"result_data"=>$result_data));
}

There are three required parameters – $user_token, $mastodon_url, and $toot_content.

To make use of the function, create an application within your Mastodon account. In most cases you’ll find this in “Preferences -> Development“, then click “New Application“.

Fill in the fields – just use the URL of your website for the requested URLs. We won’t be doing any two-way communication between your application and Mastodon, so they won’t matter in this instance. Save your new application.

Take note of the “Your access token” value – this is what needs to be passed to the function as $user_token. Remember, you must keep this token secret and secure – as anyone with the token will be able to post to Mastodon as if it were you.

The value of $mastodon_url should just be the name of your Mastodon instance – eg: for me, it is “aus.social”.

The value of $toot_content is exactly what it sounds like – whatever you want to post to Mastodon via your script.

The first line in the function does a little cleanup on the content, just to remove crappy characters – I’m not 100% sure this is needed for Mastodon, but I carried this over from my corresponding Twitter tweet function, and it seems to not cause any issues here – so it’s there!

And that’s it. The function returns an array with some diagnostic information – (did it/didn’t it work?) – and the ID of the toot posted, if it was successful.

While the above function is written in PHP, given I’ve chosen to use PHP’s cURL library, if your chosen scripting language is not PHP it should be pretty straightforward to use the cURL library for whichever language you prefer, to come up with an equivalent script.

Over time I’ll delve more into what the Mastodon API can achieve, but in the meantime, happy automated tooting!