Api

From ShackWiki
Jump to: navigation, search

nuShack has an API now for posting to shacknews.


Posting to Chatty

Using curl from the command line:

New root message:

curl -u "<USERNAME>:<PASSWORD>" --data-urlencode "content_type_id=17" --data-urlencode "content_id=17" 
--data-urlencode "body=<MESSAGE>" http://www.shacknews.com/api/chat/create/17.json

Response

{"action":"create","content_id":"17","content_type_id":"17","body":"<MESSAGE>",
"method":"post","format":"json","data":{"post_insert_id":"<numeric POSTID>"}}

For replying to a post:

curl -u "<USERNAME>:<PASSWORD>" --data-urlencode "content_type_id=17" --data-urlencode "content_id=17"
--data-urlencode "body=<MESSAGE>" --data-urlencode "parent_id=<PARENT ID>" http://www.shacknews.com/api/chat/create/17.json
{"action":"create","content_id":"17","content_type_id":"17","body":"<MESSAGE>",
"method":"post","format":"json","data":{"post_insert_id":"<numeric POSTID>"}}

Error response when hitting the PRL:

{"action":"create","content_id":"17","content_type_id":"17","body":"<MESSAGE>", "method":"post","format":"json",
"data":{"error":[{"message":"Please wait a few minutes before trying to post again.","code":-1}]}}

There is also a 5000 character limit on all posts

{"action":"create","content_id":"17","content_type_id":"17","body":"<MESSAGE>", "method":"post","format":"json",
"data":{"error":[{"message":"Please post less then 5000 characters long.","code":-1}]}}

See also