How to set up smartphones and PCs. Informational portal
  • home
  • Windows 8
  • How to end a relationship and not lose mutual friends. Algorithm for determining the section "Possible friends

How to end a relationship and not lose mutual friends. Algorithm for determining the section "Possible friends

Hello habrauser.
Once I had a need to find a person, knowing his appearance and knowing about his membership in a certain club. I also owned the addresses (VKontakte) of the pages of two other members of the club. Almost certainly the person they were looking for was friends with each of them. This problem could be solved in different ways. In this article I will write about how I implemented the solution using the vk.com API.
1 task
Create a service that will find all common friends of two separate users without requiring verification and a social network account for users of the service. Get data about mutual friends:
  • the photo
Implement a task based on the VKontakte API. Write a hotel class for this.
2.Solution
2.1 defining the required API methods
Go to method list API. And having searched, we find what we need.

To get the user's friends, there is a method friends.get.
friends.get - returns a list of the user's friend IDs or extended information about the user's friends (when using the fields parameter).

And, what is important, as part of the solution to the task at hand, this is an open method that does not require an access_token.

There is only one required parameter:

Using this method, you can get information about all the friends of each of our two sets, but this approach will not be optimal. User A can have 2000 people as friends, only 3 people will intersect with the friends of user B. In this case, information about 1997 users will be unnecessary for us, and the resources spent on obtaining it will be wasted.
We will request only user identifiers, and having received the numbers we need (which belong to the set A and B), we will already select information by them.

There is a method to get information about a user users.get.
users.get -Returns extended information about users.

This method also does not need an access_token, that is, it is ideal for our task.


In user_ids, we will pass an array of user IDs that occur in both sets.
We want to get only an avatar with a size of 100 * 100, for this we pass the value photo_100 in the fields parameter.

2.2 Moving on to the practical side
I wrote a simple class in php:

Class VkFriends (public function clean_var ($ var) ($ var = strip_tags ($ var); $ var = preg_replace ("~ \ D + ~", "", $ var); $ var = trim ($ var); return $ var;) public function get_friends ($ u_id) ($ friends = file_get_contents ("https://api.vk.com/method/friends.get?user_id=". $ u_id); $ friends = json_decode ($ friends); if (! isset ($ friends-> error)) (return $ friends;) else (return "";)) public function mutual_friends ($ friends) ($ mutual = array_intersect ($ friends-> response, $ friends-> response ); if (! empty ($ mutual)) (return $ mutual;) else (return "";)) public function get_users_info ($ users) ($ u_ids = implode (",", $ users); $ u_info = file_get_contents ("https://api.vk.com/method/users.get?user_ids=".$u_ids."&fields=photo_100"); $ u_info = json_decode ($ u_info); return $ u_info;) public function view_user_info ( $ u_info) ($ uid = $ u_info-> uid; $ first_name = $ u_info-> first_name; $ last_name = $ u_info-> last_name; = $ u_info-> photo_100; print ("

");) public function view_users_info ($ users_info) (for ($ i = 0; $ i response); $ i ++) ($ this-> view_user_info ($ users_info-> response [$ i]);)))

Now let's see our class in action:

$ vkf = new VkFriends; $ u_id = $ vkf-> clean_var ($ _ POST ["u1"]); // clean variables from POST $ u_id = $ vkf-> clean_var ($ _ POST ["u2"]); if (($ u_id! = "") && ($ u_id! = "")) (echo "

"; $ friends = $ vkf-> get_friends ($ u_id); // getting friends list from user with u_id $ friends = $ vkf-> get_friends ($ u_id); if (($ friends! =" ") && ($ friends! = "")) ($ mutual = $ vkf-> mutual_friends ($ friends); // create new array from intersect arrays if ($ mutual! = "") ($ users_info = $ vkf-> get_users_info ($ mutual ); // getting info about users that are mutual $ vkf-> view_users_info ($ users_info); // view information about selected users) else (print ("
Hello habrauser.
Once I had a need to find a person, knowing his appearance and knowing about his membership in a certain club. I also owned the addresses (VKontakte) of the pages of two other members of the club. Almost certainly the person they were looking for was friends with each of them. This problem could be solved in different ways. In this article I will write about how I implemented the solution using the vk.com API.
1 task
Create a service that will find all common friends of two separate users without requiring verification and a social network account for users of the service. Get data about mutual friends:
  • the photo
Implement a task based on the VKontakte API. Write a hotel class for this.
2.Solution
2.1 defining the required API methods
Go to method list API. And having searched, we find what we need.

To get the user's friends, there is a method friends.get.
friends.get - returns a list of the user's friend IDs or extended information about the user's friends (when using the fields parameter).

And, what is important, as part of the solution to the task at hand, this is an open method that does not require an access_token.

There is only one required parameter:

Using this method, you can get information about all the friends of each of our two sets, but this approach will not be optimal. User A can have 2000 people as friends, only 3 people will intersect with the friends of user B. In this case, information about 1997 users will be unnecessary for us, and the resources spent on obtaining it will be wasted.
We will request only user identifiers, and having received the numbers we need (which belong to the set A and B), we will already select information by them.

There is a method to get information about a user users.get.
users.get -Returns extended information about users.

This method also does not need an access_token, that is, it is ideal for our task.


In user_ids, we will pass an array of user IDs that occur in both sets.
We want to get only an avatar with a size of 100 * 100, for this we pass the value photo_100 in the fields parameter.

2.2 Moving on to the practical side
I wrote a simple class in php:

Class VkFriends (public function clean_var ($ var) ($ var = strip_tags ($ var); $ var = preg_replace ("~ \ D + ~", "", $ var); $ var = trim ($ var); return $ var;) public function get_friends ($ u_id) ($ friends = file_get_contents ("https://api.vk.com/method/friends.get?user_id=". $ u_id); $ friends = json_decode ($ friends); if (! isset ($ friends-> error)) (return $ friends;) else (return "";)) public function mutual_friends ($ friends) ($ mutual = array_intersect ($ friends-> response, $ friends-> response ); if (! empty ($ mutual)) (return $ mutual;) else (return "";)) public function get_users_info ($ users) ($ u_ids = implode (",", $ users); $ u_info = file_get_contents ("https://api.vk.com/method/users.get?user_ids=".$u_ids."&fields=photo_100"); $ u_info = json_decode ($ u_info); return $ u_info;) public function view_user_info ( $ u_info) ($ uid = $ u_info-> uid; $ first_name = $ u_info-> first_name; $ last_name = $ u_info-> last_name; = $ u_info-> photo_100; print ("

");) public function view_users_info ($ users_info) (for ($ i = 0; $ i response); $ i ++) ($ this-> view_user_info ($ users_info-> response [$ i]);)))

Now let's see our class in action:

$ vkf = new VkFriends; $ u_id = $ vkf-> clean_var ($ _ POST ["u1"]); // clean variables from POST $ u_id = $ vkf-> clean_var ($ _ POST ["u2"]); if (($ u_id! = "") && ($ u_id! = "")) (echo "

"; $ friends = $ vkf-> get_friends ($ u_id); // getting friends list from user with u_id $ friends = $ vkf-> get_friends ($ u_id); if (($ friends! =" ") && ($ friends! = "")) ($ mutual = $ vkf-> mutual_friends ($ friends); // create new array from intersect arrays if ($ mutual! = "") ($ users_info = $ vkf-> get_users_info ($ mutual ); // getting info about users that are mutual $ vkf-> view_users_info ($ users_info); // view information about selected users) else (print ("

The social network "VKontakte" is one of the most popular Internet projects in all of Russia and the countries of the post-Soviet space. Every day, year after year, the resource is used by millions of users who visit the site vk.com in order not only to communicate with each other, but also to find out the news, listen to your favorite audio recordings, watch a movie or TV series, find out something interesting and even outline. where to go for a wardrobe update.

At the moment, everyone can add up to 10 thousand other "inhabitants" of the social network as friends, and, as statistics show, the average user of the resource has about 200-300 friends in his friends. Nevertheless, looking through the list of your VKontakte friends, you can unexpectedly find that they are located in a different order and can sometimes change places. Why is this happening and how is this entire list formed?

As it was before

Before giving an answer to the above question, I would like to remind you how the VKontakte friends list was formed several years earlier. Until a few years ago, people displayed in a user's friend lists were sorted by rating. Everything is clear here: the higher the user's page rating was, the higher it was displayed in the friends list. The rating could be obtained for filling out information on your own page or for purchasing additional votes. Later, it was decided to abandon the rating, which greatly upset users who bought a large number of votes and / or presented them to other "inhabitants" of the social network.

How the list of friends is formed now

Now the list of friends in the most popular social network is being formed in a different way: the first positions in the list are those users with whom you communicate most often. However, sorting the list of VK friends in this way may puzzle some users. For example, some wonder why a person with whom communication is extremely rare is so high on the list. The answer is simple - when forming the list, not only messages are taken into account, but also likes, page views, replies, comments to posts. It turns out that not only the user with whom you do not communicate so much can become the first in your list of friends.

However, there is one small exception to this rule: users whom you recently added to your friends list are usually located on the 5th or 6th place of the list so, according to the developers of the social network, so that you do not lose sight of them.

The order of the friends who are on the site

Now it's worth mentioning how users from the online friends list are sorted. Here, by and large, the principle is exactly the same: the location of friends converges with that in the general sequence, though only those users who are online are shown. If you use the options "Colleagues", "Best Friends" and the like, then the distribution of the lists of friends in them will also be the same.

How other users' friends list is arranged

If the situation with the location of our own friends is already more or less clear, then what about the friends of other users, whom we see from our own page? Everything is a little different here: the distribution of friends here is based on the number of common acquaintances with the person whose page you are viewing. In the event that you do not have mutual friends, the list of friends is formed according to the date of registration of users on the site.

Can the order be changed?

After everything has become clear about sorting VKontakte friends, you can talk about whether this order can be changed. Unfortunately, this function was not provided by the developers of the social network, so you cannot change the order of the friends yourself.

If you want someone close to you to always remain at the top of your friends list, try to communicate with them more. Otherwise, keep communication to a minimum. However, do not forget that no social networks can replace you with real communication with friends and people close to you!

The social network VKontakte unites people, and various algorithms are constantly being introduced into it, so that it is more convenient for users to find their friends, relatives and just acquaintances with whom they could see several times, but when they met, they did not have time or did not want to be friends with each other ... One of the ways to quickly replenish your friends list with acquaintances is to use the Possible Friends tool on VKontakte. Within the framework of the article, we will consider the principle of operation of this algorithm, as well as how to use it.

How to see possible friends on VKontakte

To see the users whom the social network VKontakte considers to be your potential friends, just go to your page in the "Friends" section. In the lower right corner of the page that opens, under the filtering lists of current friends, there will be a block "Potential friends".

Each time you visit the page, it is rendered in a new way. This block displays 5 people you may know. If you want to see more possible friends, click in this block on the button "Show all".

After that, a page will open, which displays all users who are defined as possible friends for your page. Depending on how actively you use your VKontakte account, as well as on a number of other factors, the number of user data may vary. Scroll down the page and new prospective friends will be loaded automatically.

Please note: Despite the fact that on this page there are all kinds of filters on the top and on the right, they in no way allow you to filter the list of possible friends. That is, if you use the search from above and, for example, try to find all possible friends with the name "Sergey", the social network will simply start looking for users with the name "Sergey" in its database, not focusing on the list of possible friends selected for you.

How are possible friends of VKontakte determined?

The VKontakte company does not disclose the algorithms by which a list of possible friends is formed for each specific user. However, observations show that clearly the list of possible friends depends on:

It is important to note that there is no way for the user to see who he is listed as a prospective friend. That is, this information is not mutual for users. If you see that a VK user is displayed as a possible friend for you, for example, since you often visit his page, this does not mean that you will be displayed as a friend with him. Of course, except for the situation when, when you visit a page, you show activity on it in the form of likes, reposts, comments, and so on.

Have you and your ex / ex made many new friends during your relationship? Sadly, now you are breaking up. How to end a relationship with an ex / ex without losing mutual friends?

Steps

    Don't discuss your breakup with them. In such a situation, there are always two points of view. Leave yours to discuss with family and those friends with whom you knew even before you entered a relationship.

    Never say anything bad about your ex / ex. The fact that you are not discussing the breakup does not mean that you can talk nasty things about this person that are not related to the breakup. When you tell bad things to people who are your mutual friends, you put them in an extremely embarrassing position, because they want to remain faithful to both you and your ex.

    Disclose information carefully. Since these are yours are common friends, remember that whatever you tell them can get through to your ex. It can ruin all your attempts to break up in an amicable way.

    Keep in touch. This moment is very difficult, because mutual friends bond you tightly to the old relationship - both heart and mind. However, if you want to maintain friendship, you must understand that your mutual friends may simply not know how to behave with you in this situation, so you must show them (by phone call or email) that you want to continue. keep in touch. As already stated, you must be careful not to disclose information to your friends that should not reach your ex; however, share your feelings and concerns with them about what is happening so that they still feel like a part of your life. You can, for example, say, "All things considered, I feel pretty good. It's certainly not easy to start over, but I hope the worst is over and I'm ready to move on."

    If you're already dating a new person, keep them away from mutual friends. The meeting can generate resentment and negative prejudice, simply because it is new love. Friends will feel like they will betray their friend (your ex) if they like your new partner who takes his place. Until a certain moment, keep your new sympathies a secret. Wait until the "dust clears" and you do not feel solid ground under your feet - only after that you can try to acquaint mutual friends with a new sympathy.

    Speaking of your joint meetings, one should not expect that only you will be invited from the couple. Some of your friends will not want to be challenged by the difficult choice of who to invite - you or your ex / ex. Most likely, they will invite both of you with the thought that you are adults and will deal with the situation yourself. In large companies this is quite appropriate, but in a close circle of close friends it will be nelo-o-o-vko... Avoid these situations by directly asking if your ex / ex will be at the party. They will almost certainly answer you honestly. Don't throw tantrums by making the friend inviting you feel guilty. Just express your regrets if you think that at this meeting you both will be embarrassed: "Oh, okay ... I probably won't go, it will be too close company. But don't worry, you can get together another time, when there are more people and we can distract ourselves. " Smile, be kind, and thank the person for what they thought of you.

    Do not lose your dignity and act nobly. In an inappropriate attempt to reassure you that they are on "your side", friends may take a couple of attacks on your ex. You shouldn't rejoice at making fun of your ex, and you should definitely not join such jokes. Remember, these friends are likely to do the same to you when they talk to your ex.

    • Instead, calmly and impressively say something like this: “You know, guys, during the breakup I was angry / angry, but now I feel regret and I'm sad. now that we need to move on, I don’t regret the time we spent together. If it weren’t for ____ (ex / ex name), I would never have met you. " After that, just shut up. Your friends will nod back and appreciate your high moral standards.
  1. Let time take care of the rest. Parting is like a broken arm. She hurts terribly and there is little you can do after you get the cast other than give her time. All you have to do is endure the pain and cope with the changes that have occurred in your life. Over time, if you don't criticize your ex and take part in jokes on him, your friends will understand that you have gone through it and move on.

  • Over time, your friendship will grow stronger in the new environment. Friends will begin to perceive you not as part of a couple, but as an individual. Only then can you initiate them into your new romantic relationship.
  • Your friends need time too. They knew you as part of the couple they loved, and now they too need to adjust to new circumstances. They may make awkward or even angry remarks because they don't know who to blame for what happened and what to do. Be gentle with them and keep in mind that they just don't understand how to deal with the situation.
  • When attending parties or going out with your mutual friends, feel free to ask them if your ex has been invited. Explain to your friends that you need time and some personal space to be prepared for closer contact with your ex than at really crowded parties.

Warnings

  • It may turn out that some of your "friends" are not at all. Beware of spies who secretly spy on you, gathering information for your ex. This warning is especially true if you are going through a divorce. And in this situation, you will be more than ever glad that you did not open your new sympathies.
  • Take your time to deal with the breakup too much good or too much early. Remember that your mutual friends also have warm feelings for your ex. If they feel like you easily threw him out of your life, as if he was something unnecessary (even if so), friends will think that you are acting cold and heartless. Resist the temptation to show off your new pretty boyfriend (new pretty girl), and instead focus on your friends' feelings.
  • Any sarcastic or aggressive remarks about your ex will critically reduce your chances of maintaining a friendship with your mutual friends.

Top related articles