How to implement the Friends circle function in the app five likes, comments properties detailed analysis-arrow buckle technology Arrownock

Source: Internet
Author: User

How to implement a friend circle function in the app five likes, comments properties detailed analysis

Quick View comments and number of likes:

When we create a wall sticker, this wall sticker automatically comes with a comment quantity of Commentcount, likes number likecount, nasty quantity dislikecount three attributes.

When a user comments on the wall sticker, the Commentcount property of the wall sticker will grow automatically without the need for a developer to do it manually.

If the user establishes like in Like=true, then Likecount will grow automatically, conversely, Dislikecount will grow automatically.

If the user deleted the comments, or the likes of the revocation, then the corresponding Commentcount, Likecount, Dislikecount will also be automatically reduced.

There are 7 objects with these properties, namely: Comment, Event, File, location, Photo, Post, Wall.

Quick Find all the landlord's reply:

When user A creates a comment on a wall sticker, if the wall sticker was created by User B, after a comment is created, the comment automatically has the target_user_id attribute, which means the user_id value of the target object, in this scenario, target_ The value of USER_ID is the ID of User B.

This property provides developers with a lot of convenience, to find the landlord all the reply such a similar function of the cumbersome search operation no longer worry about. More than comment, like also has this attribute oh.

To set comment permissions:

The comments of a circle of friends can be commented on to everyone, or they can respond to someone's comments.

For the second case, just pass in the reply_user_id parameter when the comment is created, and the parameter will automatically turn into the user's information object when the bar comment is queried.

When you create a comment, the incoming reply_user_id represents a reply to someone, and the incoming user_id represents the user who created the comment, and you get one of these results when you query:


{   "meta": {     "code": 200,     "status":  "OK ",    " MethodName ": " createcomment "  },    " response ":  {     "comment": {       "id":  " 556acccfba82c60000000008 ",      " ParentID ": " 556accafba82c60000000007 ",        "ParentType":  "Post",       "content":   "Good job2",       "Commentcount": 0,        "Commentrate": 0,       "Likecount": 0,        "Dislikecount": 0,       "Created_at":  "2015-05-31t08 : 56:47.059z ",      " Updated_at ": " 2015-05-31t08:56:47.066z ",        "User": { &Nbsp;       "id":  "556acc01ba82c60000000005",          "username":  "user1",         "Created_at":  "2015-05-31t08:53:21.585z",         "Updated_at":  "2015-05-31T08 : 53:21.586z "      },      " Targetuser ":  {          "id":  "556acc01ba82c60000000005",          "username":  "user1",         "Created_at":   "2015-05-31t08:53:21.585z",         "Updated_at":  " 2015-05-31t08:53:21.586z "      },      " Replyuser " : {         "id":  "556acc0cba82c60000000006",          " Username ": " user2 ",        " Created_at ": " 2015-05-31t08 : 53:32.444z ",        " Updated_at ": " 2015-05-31T08:53:32.445Z "       }    }  }}



Implementation process:

Comment Function (example of Android code):


    //Send Comments     Map<String, Object> params =  New hashmap<string, object> ();     params.put ("Object_type",  "Post"); The  //type is post    params.put ("object_id",  postid);//object ID is postid     params.put ("user_id",  userid);//Userid    params.put Sending comments ("content",  content);//Comments     try {         Ansocial.sendrequest ("Comments/create.json", ansocialmethod.post, params,                                                                 new iansocialcallbaCK ()  {             @Override              public void onsuccess (JSONObject response )  {            //data into the local database, refresh the interface, send notifications to the Post's owner             //handlesuccess ();             }              @Override             publicvoid  onfailure (Jsonobject response)  {             }        });    } catch  ( arrownockexception e)  {    }



Likes features:

If you like, you only need to change the content parameter to a parameter like true, and change the Comments/create.json to Likes/create.json.

Check to be liked:

1, first create three post, respectively called Testpost1,testpost2,testpost3.

2, then add like to TestPost1 to True, add like false to TestPost2. C. Query post with the following results:

{   "meta": {     "code": 200,     "status":  "OK ",    " MethodName ":" Queryposts ",    " Page_size ": 10,      "page": 1,     "Total": 3  },   "response":  {      "Posts": [    {       "id": " 55607838dddfa58b21000008 ",      " title ":" TestPost1 ",        "Imageids": [],       "Commentcount": 0,        "Commentrate": 0,       "Likecount": 1,        "Dislikecount": 0,       "Created_at": "2015-05-23t12 : 53:12.863z ",      " Updated_at ":" 2015-05-23t12:53:12.863z ",        "like": {         "id": "55607865dddfa58b2100000b",          "Positive": true,         "created_ At ":" 2015-05-23t12:53:57.947z ",        " Updated_at ":" 2015-05-23T12 : 53:57.949z "        }    },     {       "id": "55607840dddfa58b21000009",        "title": "TestPost2",       "Imageids": [],        "Commentcount": 0,       "Commentrate": 0,        "Likecount": 0,       "Dislikecount": 1,        "Created_at": "2015-05-23t12:53:20.635z",       " Updated_at ":" 2015-05-23t12:53:20.635z ",        "like": {         "id": " 55607872dddfa58b2100000c ",        " positive ": false,          "Created_at": "2015-05-23t12:54:10.665z",          "Updated_at": "2015-05-23t12:54:10.666z"       }     },    {       "id": "55607847dddfa58b2100000a",        "title": "TestPost3",       "Imageids":  [ ],       "Commentcount": 0,       "CommentRate" : 0,       "Likecount": 0,       " Dislikecount ": 0,      " Created_at ":" 2015-05-23t12:53:27.923z ",        "Updated_at": "2015-05-23t12:53:27.924z "&NBSP;&NBSP;&NBSP;&NBSP;}]&NBSP;&NBSP;}} 


You can see that TestPost1 and TestPost2 return the like property, and their like are true and false, because of the result of creating like, the incoming like is true and false, respectively, The TESTPOST3 does not have a like attribute. PS: Not only post has such a function, Comment,event, File, location, photo also has oh. )

Invite someone to participate in a poll:

In social functions, it is often possible to see a function of voting so that when you create a poll vote in Ansocial, there are two parameters, Invite_user_ids and Invite_circle_ids, respectively. These two parameters can be used if you want to provide a vote in the app for friends or a vote in some circles.

Use is very simple, invite_user_ids that is the user's ID, multiple IDs can be used "," split, Invite_circle_ids is the circle ID, the same as the user, when the incoming Invite_circle_ids, Ansocial will automatically look for users within the circle, making development a lot more efficient.

Tips:

The above is the usual way to send comments and likes, then for a situation, reply to someone in the comment, we need to pass in the reply_user_id parameter Params.put ("reply_user_id", Replyuserid);

In this scenario we are sending a successful callback function, in addition to sending a notification to the owner of the post, we also need to send a notification to the user who reviews us. In addition, in comment and like, we also provide a target_user_id query, that is, the target object's creator ID can be directly find the relevant comments and likes, instead of the user ID first find the post, And then through the post to find comment and like. TARGET_USER_ID is to support the introduction of multiple user_id, with "," split.


How to implement the Circle of Friends feature in the App series article:

A brief analysis of the realization principle of circle of friends

Second, quickly realize the customization of user information

Three quick realization of two-way friend function

Four in the circle of friends to add the Send picture function

Five likes, comments attribute detailed analysis

The six-speed implementation of the pull-down load friend circle function

Seven fast implementation of pull-up load friends circle function

The logic and implementation of the eight page load function


This article from "Arrow Buckle technology Arrownock" blog, reproduced please contact the author!

How to implement the Friends circle function in the app five likes, comments properties detailed analysis-arrow buckle technology Arrownock

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.