recoilme / tgram

typegram: open source publishing platform
http://tgr.am
GNU General Public License v3.0
335 stars 32 forks source link

api #108

Open recoilme opened 6 years ago

recoilme commented 6 years ago

Get last 20 articles curl --header "Content-type:application/json" 'http://sub.localhost:8081/mid'

[{"ID":40,"title":"some title","body":"some body 111111..","Author":"recoilme","Image":"http://sub.localhost:8081/a/33.png","ogimage":"","CreatedAt":"2018-10-08T18:50:14.598065282+03:00","Lang":"sub","HTML":"","Plus":0,"Minus":0,"Comments":null,"ReadingTime":0,"WordCount":3,"tag":""},{"ID":39,"title":"Title test fcm2","body":"Body test fcm2..","Author":"recoilme","Image":"http://sub.localhost:8081/a/33.png","ogimage":"","CreatedAt":"2018-10-08T18:48:39.295722411+03:00","Lang":"sub","HTML":"","Plus":0,"Minus":0,"Comments":null,"ReadingTime":0,"WordCount":3,"tag":""}]

Get next 20 from article id 20 curl --header "Content-type:application/json" 'http://sub.localhost:8081/mid?p=20' response - similar

Get article curl --header "Content-type:application/json" 'http://sub.localhost:8081/@username/19'

{"ID":19,"title":"","body":"efweffefwefwefewf","Author":"username","Image":"","ogimage":"","CreatedAt":"2018-08-09T14:06:18.313579468+03:00","Lang":"sub","HTML":"\u003cp\u003eefweffefwefwefewf\u003c/p\u003e\n","Plus":0,"Minus":0,"Comments":null,"ReadingTime":0,"WordCount":0,"tag":""}

Register curl --header "Content-type:application/json" --request POST --data '{"username":"recoilme56","password":"password","privacy":"privacy","terms":"terms"}' http://sub.localhost:8081/register

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpbWFnZSI6IiIsIm5vanMiOiIiLCJ1c2VybmFtZSI6InJlY29pbG1lNTYifQ.xle4ofAfobpZh2_FbuCwNoVrVdR_mymohJIMfAUwLZQ

Login curl -v --header "Content-type:application/json" --request POST --data '{"username":"recoilme56","password":"password"}' http://sub.localhost:8081/login

"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpbWFnZSI6IiIsIm5vanMiOiIiLCJ1c2VybmFtZSI6InJlY29pbG1lNTYifQ.xle4ofAfobpZh2_FbuCwNoVrVdR_mymohJIMfAUwLZQ"

Send new post to FCM

{"to":"sub/all","data":{"ID":40,"title":"some title","body":"some body 1111114444..","Author":"recoilme","Image":"http://sub.localhost:8081/a/33.png","ogimage":"","CreatedAt":"2018-10-08T18:50:14.598065282+03:00","Lang":"sub","HTML":"","Plus":0,"Minus":0,"Comments":null,"ReadingTime":0,"WordCount":3,"tag":""}}
recoilme commented 6 years ago

@vogster Send delete post to FCM

{"to":"/topics/tst_del","data":{"ID":40,..}
recoilme commented 6 years ago

Errors

@vogster in case of errors api will return HTTP code 422 and json with error string:

{"error":"Error: key not found"}
recoilme commented 6 years ago

Post article

curl -v --header "Content-type:application/json" --header "Authorization:token somebigstring" --request POST --data '{"body":"recoilme5 passwor  pssword"}' http://sub.localhost:8081/editor/0

Update article http://sub.localhost:8081/editor/ArticleId

recoilme commented 6 years ago

Post comment

curl -v --header "Content-type:application/json" --header "Authorization:token somebigstring" --request POST --data '{"body":"recoilme5 passwor  pssword"}' 'http://sub.localhost:8081/comments/@recoilme56/41'