3

『 0x61 』- /var/log

 1 year ago
source link: https://x61.sh/log/2022/12/20221205T205745-honk-cli.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
[x61]

:.: honk-cli

Well not really a honk-cli but how to use the API, if you didn't read the manual honk(3), you should, it explain the API's options and how to interact with honk.

You already read my honk log entry and you have your own setup up and running with an user, so as the man says...

Send a POST request to /dologin with the following form values.

username
	User name.
password
	Pass phrase.
gettoken
	Must be “1”.

This will return a token to be used for future requests. The token is valid for one year.

We will send a POST request to our honk's api to get a token back in return and be able to "login" and honking all day, for this we'll use curl (in case you don't have it; $ doas pkg_add curl):

$ curl -X POST -F "username=gonzalo" \
	-F "password=ThisIsMySuperSecretPassword" \
	-F "gettoken=1" \
	https://honk.yourdomain.org/dologin

4a37bfaa91a3e942879811bd7d9ec76069
$

Perfect, now we'll be able to honk via the api using the token, again as the manual says:

honk
The action value should be “honk”. Content type should be multipart/form-data if an attachment is included. The following values are recognized:

noise
	The contents of the honk.
format
	The format of noise. Defaults to markdown. May also be html.
donk
	A file to attach.
donkdesc
	A description for the attached file.
donkxid
	The XID of a previously uploaded attachment.
placename
	The name of an associated location.
placeurl
	The url of an associated location.
placelat
	The latitude of an associated location.
placelong
	The longitude of an associated location.
timestart
	The start time of an event.
rid
	The ActivityPub ID that this honk is in reply to.
Upon success, the honk action will return the URL for the created honk.

Let's honk something with it now:

$ curl -X POST -F "token=4a37bfaa91a3e942879811bd7d9ec76069" \
	-F "action=honk" \
	-F "noise=This is a test honk while I am writing a new log entry about honk from the command line, you will read this when you read the log entry (?)" \
	https://honk.yourdomain.org/api

https://honk.yourdomain.org/u/gonzalo/h/R1KvZdD9HlsYcxq7DW

There you go, that output is the URI of your fresh honk! Go and check it out on your Internet Explorer!

Nice and easy, let's do one more, because time to time we want to honk a nice picture, so we can do that on the same way, but adding the donk parameter:

$ curl -X POST -F "token=4a37bfaa91a3e942879811bd7d9ec76069" \
	-F "action=honk" \
	-F "noise=This one is also a honk while writing the log entry, but it should have a photo in it!" \
	-F "[email protected]" \
	https://honk.yourdomain.org/api

https://honk.yourdomain.org/u/gonzalo/h/l3PM9GLBq3qY9WTX

We are done! Now you can honk from your xterm like pro! Of course you have more options to play with, for that you need to read again the manual, because you already did once right?

Now it's up to you to make a nice honk-cli to honk from the cli.


find me at: honk | mastodon | twitter | rss

page generated: 20221205T205745


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK