175 lines
11 KiB
Plaintext
175 lines
11 KiB
Plaintext
|
|
Episode: 1799
|
||
|
|
Title: HPR1799: Posting From the Command Line on Open Social Networks
|
||
|
|
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr1799/hpr1799.mp3
|
||
|
|
Transcribed: 2025-10-18 09:25:52
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
This is HBR episode 1,799 entitled, boasting from the Command Line on Open Social Networks.
|
||
|
|
It is boasted by John Culp and is about 13 minutes long.
|
||
|
|
The summary is, I explain how to boast content from the Command Line on Open Social Networks
|
||
|
|
from.io and GNU Social.
|
||
|
|
This episode of HBR is brought to you by AnanasThost.com.
|
||
|
|
It 15% discount on all shared hosting with the offer code HBR15, that's HBR15.
|
||
|
|
Better web hosting that's honest and fair at AnanasThost.com.
|
||
|
|
Hey everybody, this is John Culp in Lafayette Louisiana and today I'm going to talk about
|
||
|
|
posting to Open Social Networks from the Command Line using the API.
|
||
|
|
And by Open Social Networks, I'm going to focus in particular on two of them.
|
||
|
|
One is Identica based on the pump.io framework.
|
||
|
|
And the other is GNU Social, which is the former Identica based on StatusNet.
|
||
|
|
I use both of these although I spend most of my time on StatusNet because it just appeals
|
||
|
|
to me more.
|
||
|
|
I like the threaded conversations and it seems like the conversations actually are better
|
||
|
|
over there.
|
||
|
|
But anyway, I know a lot of people use Identica and the pump.io network and I have an account
|
||
|
|
there so I'm going to talk about that one a little bit as well.
|
||
|
|
You may never have realized that you can post to your accounts from the command line but
|
||
|
|
it's possible using the API.
|
||
|
|
Now why would you want to do this?
|
||
|
|
Why would you not just go to your client on your phone or for GNU Social use HeyBuddy
|
||
|
|
on the desktop or go to the web interface or whatever?
|
||
|
|
Why would you want to post from the command line?
|
||
|
|
Well, one of the main reasons is to be able to script it and do automated postings.
|
||
|
|
For example, when I ran my own StatusNet instance, I had an account for my cat.
|
||
|
|
And my cat would periodically post messages to the timeline.
|
||
|
|
Now clearly the cat cannot log on to the web server or to the website and type out a post
|
||
|
|
nor can he do anything from the command line or whatever.
|
||
|
|
So I had to script it for him and the way I made this possible was to use the command
|
||
|
|
line API.
|
||
|
|
And I would have a script that would do something.
|
||
|
|
I think he had a couple of things.
|
||
|
|
He would update me on the weather by scraping a certain website for weather information.
|
||
|
|
I think it was just the current temperature and conditions.
|
||
|
|
And he would also occasionally do the random password of the day and he billed himself
|
||
|
|
as security kitty.
|
||
|
|
Security kitty's random password of the day and it could be any number of characters.
|
||
|
|
But he would generate a random password and then post a message to my timeline or to his
|
||
|
|
timeline to which I was subscribed.
|
||
|
|
And I said, this is the security kitty's random password of the day.
|
||
|
|
And so it's just a fun thing to do.
|
||
|
|
Some people like to create bots.
|
||
|
|
The bot is, I don't even know exactly how to describe it, but it's an automated account
|
||
|
|
that does various things depending on what kind of bot it is.
|
||
|
|
There are a few bots on the status net network and they, one of them at least, I wish I could
|
||
|
|
remember its name, but it reads your timelines and will generate random bits of text based
|
||
|
|
on everything that you've posted and then post it to you.
|
||
|
|
And so you see bits of your own text all mangled together in funny ways and it's just a fun
|
||
|
|
nerdy thing to do.
|
||
|
|
So being able to post from the command line means that you can, if you spend a lot of
|
||
|
|
time in a terminal environment, then you can post your timeline from there.
|
||
|
|
And I have a couple of scripts that I use in conjunction with Blather, the speech recognition
|
||
|
|
program where all I have to do is select a bit of text and then I will speak a command.
|
||
|
|
And then whatever text is selected is copied into my clipboard and used as the text of
|
||
|
|
a post to one of my timelines or to all of them for that matter.
|
||
|
|
And so let's just look at how you do this.
|
||
|
|
So on the GNU social platform or status net, the basic command to post a message to your
|
||
|
|
timeline, you have to use the curl command and I've put the entire command in the show
|
||
|
|
notes.
|
||
|
|
And it is curl space dash s space, double dash basic space, double dash user followed
|
||
|
|
by the username and a colon and your username password space doubles.
|
||
|
|
I'll see.
|
||
|
|
So after the username and password is another space and then double hyphen data space status
|
||
|
|
equals.
|
||
|
|
And then in quotation marks, that's where you put your message, whatever the message might
|
||
|
|
be.
|
||
|
|
And that's followed by another space and then you redirect the output to dev null by doing
|
||
|
|
double dash output space slash dev slash null space.
|
||
|
|
And that is followed by the URL for your status net instance, HTTP colon slash slash in the
|
||
|
|
example here, then it goes instance.domain.com slash api slash statuses slash update.excel.
|
||
|
|
So it's rather a long command, it's not something that you would want to be typing out every
|
||
|
|
time you did this.
|
||
|
|
So clearly it's meant for scripting.
|
||
|
|
And in the show notes, I am also going to include the script that I use to post a command
|
||
|
|
or sorry, to post a message to my timeline.
|
||
|
|
And I'm not going to read this whole thing out, but in general terms, it's a bash script
|
||
|
|
and you give it your username and password.
|
||
|
|
And I do it as variables.
|
||
|
|
And then I create a text file or like a variable that will hold the message text.
|
||
|
|
Then I have, since I'm launching this with a voice command, I give it a virtual keystroke
|
||
|
|
that does control plus C and that will copy whatever text I have selected into the clipboard.
|
||
|
|
And then I follow that up by doing the xclipspace-o to send it out of the clipboard and redirect
|
||
|
|
it to the text file that I had set up before.
|
||
|
|
Then I give it a sleep command.
|
||
|
|
I must have done that because I found that it was trying to do things too fast and choking
|
||
|
|
on something.
|
||
|
|
So I have it sleep for 0.5 seconds.
|
||
|
|
And that is followed by the entire command that I just read out to you.
|
||
|
|
And where it says double dash data space status equals, instead of putting the actual text
|
||
|
|
of the message in there, I have it do dollar sign open parenthesis cat space open quote
|
||
|
|
dollar sign text close quote close parenthesis close quote.
|
||
|
|
And so what that does is it says for the status message, what you're going to do is cat
|
||
|
|
the text file and then stick it right there and that's the message.
|
||
|
|
And after that, there's just a bit of cleanup to remove the temporary file that held the
|
||
|
|
text and it exits and then of voila, there is a message appearing on my timeline.
|
||
|
|
So that's how you do it on GNU social or status net.
|
||
|
|
On pump IO, it's a little bit more difficult to set up.
|
||
|
|
You have to install the pump IO software on your computer.
|
||
|
|
You don't have to be running a server, but you do have to have the pump IO code, which
|
||
|
|
is a node application and I'm not going to go into the specifics of how to get it and
|
||
|
|
set it up.
|
||
|
|
I'm going to link to their website so that you can go and read about it if you're interested
|
||
|
|
in this.
|
||
|
|
But once you have all of the node stuff and the pump IO software installed, then you will
|
||
|
|
have to get a, let's say you have to allow command line access to your account by getting
|
||
|
|
a command line access token kind of thing for authentication.
|
||
|
|
And then you might have to authorize the user as well and I've put examples of the commands
|
||
|
|
to run to do that in the show notes.
|
||
|
|
The pump hyphen register hyphen app and then you give it the URL for your domain or whatever
|
||
|
|
instance you're running on and tell it which port and then the title of the thing that's
|
||
|
|
trying to request access.
|
||
|
|
In this case, I use CLI for command line and then there's another command that can authorize
|
||
|
|
that username.
|
||
|
|
And once you have this all done, then you can post a message to your timeline from the
|
||
|
|
command line.
|
||
|
|
And to do that, you do the pump-post-note command, pump-post-note with hyphens in between
|
||
|
|
each word, followed by the s flag, followed by instance.domain.com, that's just a, I made
|
||
|
|
a domain, I did domain, I did.
|
||
|
|
And then the dash capital P, space 443 for the port number, space-P, space-U, followed
|
||
|
|
by your username, space-N, I guess that represents note.
|
||
|
|
And then that finally is followed by the text of your post.
|
||
|
|
In this case, I just put hello world in the show notes example.
|
||
|
|
And then I also put a script of mine, the script that I use to post to my own pump-io timeline.
|
||
|
|
And again, I launch it with a voice command, I select some text and post it to the timeline.
|
||
|
|
Now to get that text normally, I use my little dictation box, which is something that hooks
|
||
|
|
into the Google Web Speech API.
|
||
|
|
And so I can dictate a message and then put it in a text editor to do a little cleanup
|
||
|
|
because it usually gets one or two things wrong.
|
||
|
|
And once I have it the way I want it, I select the text, speak the command, and it posts
|
||
|
|
it to my timeline.
|
||
|
|
So that's how I post to both of those networks.
|
||
|
|
Now you can also do this to post to Twitter.
|
||
|
|
I'm not going to run that down too much, but I did get a heads up from someone on my
|
||
|
|
GNU Social Timeline today about the command line client for Twitter called TTY T-T-E-R-T-E-R-T-E-T-E-R.
|
||
|
|
I'm not sure how you would pronounce that, but anyway, it's a command line client for Twitter.
|
||
|
|
And so I installed that, it's a perl script.
|
||
|
|
And it seems to work very well.
|
||
|
|
There is a mode that you can call it in where it doesn't open up the client, but simply
|
||
|
|
post some message to your timeline, and that's the way I use it.
|
||
|
|
So I actually have now one command.
|
||
|
|
If there's something I want to post to all three of my social networks, I will select the
|
||
|
|
text and speak that command, and it will post it in all three places.
|
||
|
|
So anyway, it's pretty fun.
|
||
|
|
If you like to do scripting and like to do fun things like that, then you should try it
|
||
|
|
out.
|
||
|
|
It's pretty cool to be able to do these kinds of things.
|
||
|
|
I'm going to have some links in the show notes to GNU Social, to Identica, and to information
|
||
|
|
about pump I-O, and also to a limp, sorry, a limp, a list of pump I-O clients.
|
||
|
|
And then I also have a screencast that I made a couple of years ago demonstrating how I
|
||
|
|
use a bladder voice command to post a message to my timeline.
|
||
|
|
And so that's on YouTube, and I'll have a link to that as well.
|
||
|
|
Anyway, that's it.
|
||
|
|
I hope you have enjoyed hearing about how to post messages to your social media timelines
|
||
|
|
from the command line.
|
||
|
|
Bye.
|
||
|
|
You've been listening to Hacker Public Radio at Hacker Public Radio.org.
|
||
|
|
We are a community podcast network that releases shows every weekday, Monday through Friday.
|
||
|
|
Today's show, like all our shows, was contributed by an HBR listener like yourself.
|
||
|
|
If you ever thought of recording a podcast, then click on our contribute link to find
|
||
|
|
out how easy it really is.
|
||
|
|
Hacker Public Radio was founded by the Digital Dove Pound and the Infonomicon Computer Club,
|
||
|
|
and is part of the binary revolution at binrev.com.
|
||
|
|
If you have comments on today's show, please email the host directly, leave a comment on
|
||
|
|
the website, or record a follow-up episode yourself.
|
||
|
|
On this otherwise status, today's show is released under a Creative Commons Attribution
|
||
|
|
ShareLive 3.0 license.
|