C
C
cyberlain2019-09-09 11:39:24
JavaScript
cyberlain, 2019-09-09 11:39:24

VK api. How to get json of all Olegs from the city of Kukuev?

Show examples of users.search
(I already wrote users.search?q=Oleg&access_token=********** so far it swears at the wrong token, although I inserted the protected key as it is, it’s not clear what to do next

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2019-09-09
@cyberlain

Possible Cause of the Error
The users.get() method can be called with one of three key types:

  • service key (applications)
  • community key
  • user key
while users.search() can only be called with a user key.
If users.get()is fired, but users.search()no token error is returned, it is most likely that a Community token or an Application Service Key is being used.
Obtain a User Key . To do this, you need to create your own VK application or use a ready-made one. You do not need to request special rights, just get a token.
In the request to users.search()search only in city N, you will first need to find idthis city N in the Directory of VK cities. There is a database.getCities() method for this - clicking on the link (at the bottom of the page) will perform a search and return several settlements similar to Kukuevo, each with its ownid.
In total, users.search()you will pass the following parameters to the method:
  1. v=5.101— API version, required
  2. access_token=XXXXX- User token in any VK application
  3. count=1000- without this parameter will return only 20 results
  4. q=Олег- search string
  5. city=123— id of the city of Kukuyevo, obtained earlier in database.getCities()
  6. sex=2- male gender (optional)
  7. age_from=18- the desired Oleg graduated from school
  8. age_to=24- probably, the desired Oleg has not yet received a pension

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question