VK的Web API(简单) [英] VK Web API (simple)

查看:1401
本文介绍了VK的Web API(简单)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从VK community.The问题调用方法photos.get并取回照片的是,我无法查看OID即owner_id(用于请求所需的参数之一),当我参观URL。例如,当我浏览某社区,我最终得到一个URL,如 http://vk.com/picsa,而是这个picsa,我需要一个可以传递作为参数的数字。我如何获得owner_id而不是从URL?


解决方案

您可以使用 groups.getById API方法。它不需要任何身份验证:

https://api.vk.com/method/groups.getById? group_ids = picsa

您将得到JSON格式的默认组实体:

  {
    回应:[
        {
            GID:37460919,
            名:美,
            SCREEN_NAME:picsa,
            is_closed:0,
            类型:页面
            //不同尺寸的照片去这里
        }
    ]
}

现在,您可以提取社区的ID( GID ),并可以在其他API请求使用它。你可以得到关于在同一时间多个社区的信息 - 你需要用逗号将它们enumarate( /method/groups.getById?group_ids=picsa,othergroup,somename )<。 / p>

当您使用 photos.get 法工作,请记住,这VK使用的 ID为社区和页面值。

例如,搜索
/method/photos.get?owner_id=123456789 表示用户123456789照片和结果
/method/photos.get?owner_id=-123456 表示照片社区123456的。

I would like to call the method "photos.get" and retrieve photos from a VK community.The problem is that I am unable to view the oid i.e owner_id( one of the parameters required for the request) when I visit the URL. For example, when I browse a certain community, I end up getting a URL like "http://vk.com/picsa".Instead of this picsa, I require a number that can be passed in as an argument. How do I get the owner_id instead from the URL?

解决方案

You can use groups.getById API method. It does not require any authentication:

https://api.vk.com/method/groups.getById?group_ids=picsa

You will get the default group entity in JSON format:

{
    "response": [
        {
            "gid": 37460919, 
            "name": "AMERICA", 
            "screen_name": "picsa", 
            "is_closed": 0, 
            "type": "page", 
            // photos of different size go here
        }
    ]
}

Now, you can extract the community's ID (gid) and will be able to use it in other API requests. You can get information about several communities at the same time - you need to enumarate them with commas (/method/groups.getById?group_ids=picsa,othergroup,somename).

When you work with photos.get method, keep in mind, that VK uses negative ID values for communities and pages.

For example,
/method/photos.get?owner_id=123456789 means "photos of user 123456789" and
/method/photos.get?owner_id=-123456 means "photos of community 123456".

这篇关于VK的Web API(简单)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆