How to realize the three-way function of the circle of friends in the app fast bidirectional friend function--arrow buckle technology Arrownock

Source: Internet
Author: User

How to realize the three-way function of the circle of friends in the app fast bidirectional friend function

In the use of social apps, it is a necessary scenario for users to add friends to each other, and this technology is shared here to show you how to use Ansocial's friend to implement Weibo fans and buddy mechanisms.

Weibo fan mechanism:

Weibo is a one-way friendship chain that starts with a single user who has followers and fans. Friend can be used to achieve the following scenarios: User A is concerned about B, user C is concerned about a, that B has a fan a,a fan C.

Specific implementation methods:

User A is concerned about B, calling new Friend (Friends/add.json), target_friend_id user b,user_id as User A in the parameter.

User C is concerned with a, call new Friend (Friends/add.json), parameter target_friend_id user a,user_id for User C.

Search for a fan, call view followers (Friends/followers.json), parameter user_id for user A.

In the result data returned by the server, Friendproperties Ismutual is false, which means that a is concerned about others, others are not concerned with a. True indicates that the two sides are concerned about each other. Search for A's attention, call view Friend (Friends/list.json), parameter in user_id for User A.

QQ friend Mechanism:

and QQ friends belong to the two-way friendship chain, one user to send a friend request to another user, another user can agree, the two sides become friends. Friend can be used to achieve the following scenarios: User A add B for friends success, User C add a for friends failed.

Specific implementation methods:

1. User A adds User B as a friend success.

The first step is to call send Friendrequset (Friends/requests/send.json), user_id the user a,target_user_id to User B in the parameter.

In the second step, User B calls accept Friendrequest (Friends/requests/approve.json), which request_id the request ID that was created before user A sends a friend request.

In the third step, User B adds a as a friend, calls new Friend (Friends/add.json), and target_friend_id user a,user_id as User B in the parameter.

2. User C Add User A is a friend failure.

The first step, send a friend request, here refer to the above steps, no longer repeat.

In the second step, user A calls Deny Friendrequest (Friends/requests/reject.json), which request_id the request ID that was created before user A sends a friend request. View A's buddy list, call view Friend (Friends/list.json), parameter user_id for user A. In the result data returned by the server Friendproperties Ismutual is false, that is, a unilaterally add other users as friends, other users did not add a as a friend. True indicates that both sides have become friends with each other.

Tips:

Friend also provides an API to delete friends, view friend requests, delete friend requests, and you are welcome to use them.

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 realize the three-way function of the circle of friends in the app fast bidirectional friend function--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.