R
R
romellow2017-01-29 13:35:00
PHP
romellow, 2017-01-29 13:35:00

Is the person subscribed to such a group and did he leave photos there?

Good day! Is it possible to find out somehow through the VK API whether a person is subscribed to the same groups as me and whether he left photos there? How can this be done in JS? Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Sokolov, 2017-01-29
@romellow

The users.getSubscriptions() method returns the user's subscriptions. If user_id is not specified, it will return your subscriptions. Here is such a simple code in the execute() procedure (insert it right on that page and “Execute”) will return two arrays: yours and its group id:

var uid=12345; 
return {
  "my": API.users.getSubscriptions().groups.items,
  "her": API.users.getSubscriptions({"user_id":uid}).groups.items
};

The first line specifies the id of "that user" with whom to compare.
These two arrays remain to be compared. You can execute the following code in the scratchpad of the browser:
var r = 
{"response":.....} // тут целиком ответ из метода execute
;                  // и точка-с-запятой в конце.
var common = [];   // сюда попадут id общих групп
for(var i=0;i<r.response.my.length;i++){
  if( !!~r.response.her.indexOf( r.response.my[i])) 
    common.push(r.response.my[i]);
}
common;   // если в Scratchpad Firefox'а нажать Ctrl+L, 
          // код выполнится а в коммент вставится содержание этого массива

Whether you posted photos - you need to view the entire photo using the photos.getAll() method . The owner_id parameter - in turn, each of the common groups. For each photo, look at the value of the user_id field - you need only those where it is equal to the desired user.
For one method call, you can get up to 200 photos, so add the parameter count=200 and scroll through the offset parameter 200 images deep into the history. You can again use the execute method to charge the collection - this will be 25 * 200 = 5000 photos per call.

I
iBird Rose, 2017-01-29
@iiiBird

find out if a person is subscribed to the same groups as me

https://vk.com/dev/users.search
If the posts are anonymous, you won't know. if not - through https://vk.com/dev/wall.get you parse posts for the presence of this user
if you search for group albums - https://vk.com/dev/photos.getAlbums
https://vk.com/dev/Javascript_SDK

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question