Skip to content

API Comment

mdt edited this page Jul 5, 2013 · 2 revisions

Get a Comment

This requests will send back one comment.

/comment/{commentID}

Responds with a Comment Model JSON containing a User Model.

Example

HTTP GET Request: http://www.example.com/rest.php/comment/16

Reply:

{
	"id": 16,
	"ctime": "1368712658",
	"TextID": "bbt-c263",
	"Content": "This is a Comment!",
	"StartIndex": "1543",
	"EndIndex": "1630",
	"Likes": 2,
	"Dislikes": 0,
	"UserVote": 0,
	"User": {
		"Name": "Johanna",
		"Logo": "\/typo3conf\/ext\/we_betatext\/default.jpg",
		"Verified": 1
	}
}

Post a new Comment

To make sure, the position of the new comment is correct, we need to tell the Server where the new span "comment-20" should go. If someone else already made a new comment, we get the new text version, fill in our new comment and try again until we get Version+1.

Example

HTTP POST Request: http://www.example.com/rest.php/comment

POST Variables:

{
	"TextID": "bbt-c216",
	"Content": "New comment text.\nSome more text.",
	"StartIndex": 1514,
	"EndIndex": 1545,
	"Likes": 0,
	"Dislikes": 0,
	"UserVote": 0,
	"CommentedText": "this is the text I commented on",
	"User": {
		"Name": "mkb",
		"Logo": "/typo3conf/ext/we_betatext/default.jpg",
		"Verified": 1,
		"_logged_in": true,
		"profile_url": "",
		"pwreset_url": "",
		"register_url": ""
	},
	"numVotes": 0,
	"voteClass": "acceptanceLevel-0",
	"footnoteid": "c49"
}

Reply:

{
	"TextID": "bbt-c216",
	"Content": "New comment text.\nSome more text.",
	"StartIndex": 1514,
	"EndIndex": 1545,
	"CommentedText": "this is the text I commented on",
	"id":20
}

Now we need to put the new comment at the right place:

HTTP PUT Request: http://www.example.com/rest.php/text/bbt-c216

PUT Variables:

{
	"TextID": "bbt-c216",
	"uid": "1",
	"pid": "57",
	"tstamp": "1360930616",
	"crdate": "1354203858",
	"cruser_id": "0",
	"fe_cruser_id": "4",
	"deleted": "0",
	"hidden": "0",
	"Version": "9",
	"Content": "<p><span class='savedComment comment-1'>Lorem ipsum</span> dolor sit amet, consectetur adipisicing elit. Laudantium, maiores, culpa, eaque eius fuga officia in nihil nostrum nesciunt porro enim aut sit quod suscipit repellat quisquam fugit corporis voluptatibus!
		<span class='savedComment comment-20'>this is the text I commented on</span>
		Lorem ipsum dolor sit amet, consectetur adipisicing elit. Porro, non, culpa saepe <span class='savedComment comment-4'>libero est cumque quasi temporibus</span> id optio inventore ut incidunt quaerat a maiores eaque dignissimos debitis quis ea!</p>",
	"ContentRaw": null,
	"CommentID": 20
}

Reply:

{
	"TextID": "bbt-c216",
	"Version": 10,
	"Content":"<p><span class='savedComment comment-1'>Lorem ipsum</span> dolor sit amet, consectetur adipisicing elit. Laudantium, maiores, culpa, eaque eius fuga officia in nihil nostrum nesciunt porro enim aut sit quod suscipit repellat quisquam fugit corporis voluptatibus!
		<span class='savedComment comment-20'>this is the text I commented on</span>
		Lorem ipsum dolor sit amet, consectetur adipisicing elit. Porro, non, culpa saepe <span class='savedComment comment-4'>libero est cumque quasi temporibus</span> id optio inventore ut incidunt quaerat a maiores eaque dignissimos debitis quis ea!</p>"
}

Since we send version 9 and got version 10 we are done. If we had gotten Error 409, someone had been faster than us.

Delete a Comment

The link with the authhash will be send via email to infomail adress to delete inappropriate comments.

/delcomment/{commentID}/{authhash}

Example

HTTP GET Request: http://www.example.com/rest.php/delcomment/123/abcd1234

Reply: none

Home > API

Requests

  • Text
    • get a commentable text
  • Comment
    • get a comment
    • post a new comment
    • delete a comment
  • Vote
    • like/dislike a comment
  • User
    • get the logged in user
    • login a user
    • logout a user
  • Process Step
    • get the process steps of a text

Models

Clone this wiki locally