V
V
Viktor Vsk2014-05-10 12:56:11
ruby
Viktor Vsk, 2014-05-10 12:56:11

Get the id of a public or vk group by domain (name)

Vkontakte has a community widget (public or group).
On this page - vk.com/dev/Community - by substituting the domain, you can get an id (if you substitute the id, no calculations will occur).
Actually, the checkLink function on the page is responsible for the calculations, which simply sends a request to vk.com/al_pages.php?act=a_oid_by_link&al=1&url=htt... where after the last slash is the domain of the group or public.
This link returns the following content:
<!--15194<!><!>0<!>6552<!>0<!><!int>-20003922(Since this is a comment, the page itself will be empty, of course), where the last number with a minus is the id you are looking for.
Unfortunately when I use file_get_contents in php or open uri in ruby ​​I get something like:
<!--15194<!><!>1<!>4534<!>3<!>3d42c796869f4d4119
I tried some options with encodings, but nothing happened, and indeed - there are Latin and numbers. Could there be a problem with them?
I don't want to use curl, because it is not present everywhere.
Whether it is possible to receive the correct content on php "built-in" means?
javascript get requests, of course, do not work due to security policy (I tried to insert them with scripts, get, json or jsonp, it also doesn’t work somehow, because there is no callback)
It’s somehow strange that it’s not obvious how such functionality can be organized in yourself on the site. Tech support didn't answer either.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Terminaft, 2014-05-10
@viktorvsk

Why not use the API?
https://vk.com/dev
Specifically what you need:
Method description
Request and response

S
Sanya Krotov, 2019-06-22
@kollenok

When I need to find out the id or domain of any page or community ... I go to this site - searchperson.ru
and simply indicate the link to the profile or VKontakte community, so I can find out the id and domain of the page and a lot of other information.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question