I need to get a user token when the application starts. The documentation states:

При запуске приложения в строке запроса передаются дополнительные параметры, которые содержат в себе данные о пользователе и об источнике запуска. 

I'm trying to get a string using document.location.href , but it returns just the address where the application is located https://site.ru/index.php without any parameters. What am I doing wrong?

  • It would be nice to show what you are doing (what you use for authorization, what request you send, than, etc.), so that you can say that you are doing wrong. - Alexey Shimansky
  • I have a built-in iFrame application, on the page only html-markup (I see no reason to throw it), when you start the application (as stated in the documentation), the request passes parameters (I understand, such as alala.ru/index.php?par1= a & par2 = b ...) But when the query string is received, there is nothing. $ _GET also, essno, does not work. I need it to send a request to php, because javascript cannot be sent using the POST file method to the VC server - Andrey

1 answer 1

These parameters are part of the query string. For example, specifying the address https://site.ru/index.php in the application settings, the user will actually get to about this address (the names and number of GET parameters may vary depending on the type of application):

 https://site.ru/index.php ?api_url=https://api.vk.com/api.php &api_settings=0 &viewer_id=123456 &group_id=65432 &is_app_user=0 

Accordingly, if you make a redirect inside the application (for example, from https://site.ru/index.php to https://site.ru/ ), go to any link or do something else, then you will lose these GET parameters. Therefore, you can catch them only at the moment of launching the application before the first change of address , and then decide for yourself what to do with them: put in the browser cache or store somewhere on the server.

  • I sort of understood that, but after trying to make a call for window.onload, I also received just the page address without parameters. Then I tried the VK.init event (which happens even before window.onload), and the same thing anyway - Andrew
  • @Andrey, are you sure that when you open your application in an iframe, there are no redirects? - neluzhin
  • should not. My page itself is bare, except for standard tags (head, body) there is nothing there. Only script with address output. The displayed address corresponds to the IFrame address in the application. I xs - Andrei
  • Earned!)) It was just that I had indicated in Iframe without /index.php I added, now everything comes))) - Andrei