D
D
Dred Wolf2020-09-21 19:54:44
JavaScript
Dred Wolf, 2020-09-21 19:54:44

How to get data about the VK page through a JS script on an external site?

With these magic lines:

<script src="https://vk.com/js/api/xd_connection.js?2" ></script>
<script>window.name='fXD';
VK.init(function() {
// API initialization succeeded
// Your code here
console.log('API is working!\n\n')
}, function() {
// API initialization failed
// Can reload page here
console.log('API is not working...')
}, '5.124');</script>


I successfully connected the API itself to my site, but it's not at all clear how to make a request to get public data about any user by his id.
I tried to call the function with this code, but nothing is output to the console.
VK.api("users.get",{"user_ids": "durov", "fields":"city", "v":"5.89"},function(data){
     console.log(data);
 })

How to get public user data using the VK API and an external site without their authorization on the site? The idea is to put the user ID in input and output data from the returned data array. Is it real at all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Developer, 2020-09-21
@samodum

Without authorization, the API cannot be used anywhere. These are basic concepts. Without authorization - only parsing.
Authorization is precisely for this purpose made in order not to allow such cunning people like you to make anonymous requests to api and to be able to disconnect you from the service at any time

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question