Public

Notices tagged with api

How to: creating content via shcli

Socialhome has an API which covers most of the use cases for building a client. There is also a Python library/cli client that allows creating content over the API. This is a short introductory on how to use that.

shcli requires Python 3.4+. The client has only been tested on Linux, though it should work on Windows and Mac too. The only real dependency it has is the requests library.

Create a Python environment

Either install shcli in a virtualenv or globally, depending on your use case. For desktop users, a global installation makes sense.

Virtualenv

Install virtualenv for your system and create a Python 3 virtualenv and activate it.

Global install

Ensure you have a compatible Python 3 version of pip installed. For example on Ubuntu, this would be the python3-pip package.

Install shcli

Virtualenv:

pip install shcli

Globally (for example on Ubuntu):

sudo pip3 install shcli

Phew, now we're past the hard part.

Get API token

Go to your Socialhome account profile and find API token from the profile menu. Copy the token for later use. If you ever lose it, this is the place to generate a new token.

Post stuff!

Using the tool is easy. It currently only allows creating content, so commands and options are not plenty. More will be added in the future.

The client takes a command, a domain, a token and then parameters for text and visibility. The domain is your Socialhome account domain (for example socialhome.network) and token the API token copied in the previous step. To protect the token, the client always uses a HTTPS connection. This is why the protocol is not given in the command.

You can now follow/unfollow #diaspora, #friendica and #hubzilla users from #Socialhome. In preparation for user content streams, there is now a link to the user profile. Additionally, a "Home" button exists for remote users which points to the remote home profile of the user.

In other news, we also now have an #API \o/ It's not ... complete, but it does support authenticating (using a token), retrieving profile lists and doing a follow/unfollow action. Some (minimal) docs regarding the API here. For the API next will probably be creating content. Bots, anyone? ;)