-
Notifications
You must be signed in to change notification settings - Fork 2
Home
This is a minimal social network with bot friendly API for educational purposes. The code is based on eh3rrera/minitwit using the Javalin Framework. This social network is intended for students to create a social bot for.
A running server can be visited on https://www.socialbotnet.de, check it out!
Materials only exist in german. You find them on the materials subpage on the website to help you get started with programming your Bot in Java.
With a free account on heroku you can deploy the server with just one click:
Limitations: The free plan for the database is limited to 10.000 entries (users, posts and likes) and the service will sleep after 30 minutes of inactivity. This will cause delays for the first visit after inactivity.
For a local server download the .jar file from releases and run it using the following command:
$ java -jar pfad/zur/socialbotnet-3.0-jar-with-dependencies.jar
This will start the Server at localhost:30003 but without a persistent database. For a persistent database you need to create an empty PostgreSQL database yourself and configure the access by setting the environment variables JDBC_DATABASE_URL
, JDBC_DATABASE_USERNAME
and JDBC_DATABASE_PASSWORD
.
You can also run SocialBotNet on your own remote server using Dokku. For detailed instructions see build instructions below.
The Network provides an easy-to-use API for fetching users, posts and posting to walls of users.
The API provides user and posts data via HTTP-GET requests. Every request supports the GET params sortby
for any attribute (default id
), order
for asc
/desc
order (default desc
) and limit
(default 50
)
The following GET requests are supported:
-
/api/users
: Receive all registered users params: optional:sortby
, optional:order
, optional:limit
Example output: Request to/api/users?limit=2
[
{
"id":1,
"username":"root",
"hobbies":"doing stuff",
"about":"I am root"
},
{
"id":2,
"username":"user002",
"hobbies":"",
"about":""
}
]
-
/api/posts
: Receive all posts
params: optional:sortby
, optional:order
, optional:limit
Example output: Request to/api/posts?sortby=likes&limit=1
[
{
"id": 3,
"message": "This is a post written by user user001 to user004",
"publishingDate": "2014-07-14 09:46:28",
"user": { "id": 1, "username": "user001", "hobbies": "", "about": "" },
"wall": { "id": 4, "username": "user004", "hobbies": "", "about": "" },
"likes": 4,
"likedBy": [
{ "id": 1, "username": "user001", "hobbies": "", "about": "" },
{ "id": 5, "username": "user005", "hobbies": "", "about": "" },
{ "id": 6, "username": "user006", "hobbies": "", "about": "" },
{ "id": 7, "username": "user007", "hobbies": "", "about": "" }
]
}
]
-
/api/pinnwand/:username
: Receive posts posted to:username
s wall.
Example output
The output is exactly as from/api/posts/
, but filtered after username of wall.
Note: For these API calls it is necessary to provide user credentials! So include the params username
and password
in all requests.
The following POST requests are supported:
-
POST request to
/api/user/update
: Update the user profile params:
username
,password
, optional:newUsername
, optional:hobbies
, optional:about
-
POST request to
/api/post
: Create a new post on your on wall.
params:
username
,password
,message
-
POST request to
/api/post/:username
: Create a new post on:username
s wall
params:
username
,password
,message
-
POST request to
/api/like
: Like a post params:
username
,password
,postid
-
POST request to
/api/unlike
: Unlike a post params:
username
,password
,postid
To deploy the SocialBotNet on your own you only need a server with ssh access.
- (SERVER) Install dokku by following the installation instructions.
NOTE: Do not forget to complete the web-based installation! - (SERVER) Create the Dokku app:
$ dokku apps:create socialbotnet
- (SERVER) Install dokku plugin for PostgreSQL:
$ sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres
- (SERVER) Create Postgres database and connect to app
$ dokku postgres:create socialbotnet-db
$ dokku postgres:link socialbotnet-db socialbotnet
- (LOCAL) Clone the repository and add a remote for dokku:
$ git clone https://github.com/Knorrke/socialbotnet.git
$ cd socialbotnet
$ git remote add dokku dokku@ip.or.domain:socialbotnet
- (LOCAL) Deploy the app
$ git push dokku