Posting to Diaspora* via API

In the land if Diaspora*, the news of the work being done on the API yesterday was huge. The lack of a proper API has been a thorn in the side of many people. But, it's finally happening, the API is on it's way.

Still, it's a ways off from being complete but, just posting a simple text post is currently doable, at least with cURL. Of course, it's quite a handful of commands to type but, that's easily fixed with a shell script. So, I set about on writing that script.

The following was initially posted on D*:

Ok, I think this is all working pretty well. Here is my bash script that is basically a wrapper for the steps outlined here.

You can check it out at https://code.jpope.org/jpope/podwrapper.

Be sure to look over the README.

And yes, this post was posted via the script. :D

podwrapper

A bash script to post to Diaspora* via the WIP API. The API will need to be enabled on the pod you are attempting to post to.

See these posts:

https://kentshikama.com/posts/6c4b0ff01c090133da7b04015765ae01
https://kentshikama.com/posts/68f70c801c0d0133da7b04015765ae01

Requirements

mktemp
sed
awk
curl
tr

Usage

Save the script somewhere in your $PATH and make sure it's executable.

Register:

You will first need to register the script as a client, to do so, run

podwrapper -r

and answer the few questions that pop up. Once this step completes, it will run the login step automatically.

Login:

If for some reason, the login failed during registering, you can run the login step on it's own.

podwrapper -l

Post:

At the moment, posting via podwrapper will create public posts. It can post to specific aspects with a small tweak. In the future, this script will be expanded to allow choosing an aspect.

Posting a post can be done in two ways. You can use whatever editor you have set in your $EDITOR env variable (i.e export EDITOR=nano) and run:

podwrapper -p

Or, you can pipe input to podwrapper such as:

cat thisismypost.txt | podwrapper -p

Upon a successful post, the post URL will be returned.

#diaspora #api #bash #script #posting

https://pod.jpope.org/posts/1da068b01d2b01336bd10e5b4d50b4e6

EDIT And v1.1 has been pushed. Now has the option to set your preferred posting to either ‘Public’ or ‘All aspects’. Also, you can specify what config file to use instead of the default one. https://code.jpope.org/jpope/podwrapper/src/v1.1


Have a response to this post? Please use this link.