【问题标题】:VK api: how to insert user id's at get requestVK api:如何在获取请求时插入用户 ID
【发布时间】:2013-11-03 18:10:51
【问题描述】:

我尝试在 Vkontakte 获取有关用户的所有信息。 第一次,当我插入一个 uid 时,它运行良好。 但是,当我插入两个或多个 uid 时:

<?xml version=\"1.0\" encoding=\"utf-8\"?><error><error_code>100</error_code>                                               
<error><error_code>100</error_code> 
<error_msg>One of the parameters specified was missing or invalid: user_id not            
integer</error_msg><request_params list=\"true\"><param><key>oauth</key><value>1</value>

等等。

我的代码:

public System.Xml.XmlDocument GetUsers(string[] user_ids, string[] fields, string name_case)
    {
        NameValueCollection qs = new NameValueCollection();
        String uids = user_ids[0];
        String myFields = fields[0];

        for (int i = 1; i < user_ids.Length; i++)
        {
                uids += "," + user_ids[i];               
        }
        for (int i = 1; i < fields.Length; i++)
        {
                myFields += "," + fields[i];               
        }
        qs["user_id"] = uids;
        qs["fields"] = myFields;
        qs["name_case"] = name_case;

        XmlDocument doc = Logic.ExecuteCommand("users.get", qs, "");
        if (doc != null)
            return doc;
        else throw new NotImplementedException();
    }

来自 users.get 函数的文档:http://vk.com/dev/users.get

他们说,我应该使用逗号: 参数 user_ids:用户 ID 或屏幕名称 (screen_name)。默认情况下,当前用户 ID。 列出逗号分隔的字符串,允许的最大元素数为 1000。

请告诉我如何插入两个或多个 uid 来请求。 谢谢。

【问题讨论】:

    标签: c# api vk


    【解决方案1】:

    你应该使用“uids”参数名而不是“user_id”,所以在你的代码中应该是

    qs["uids"] = uids;
    

    【讨论】:

      猜你喜欢
      • 2016-08-18
      • 1970-01-01
      • 2013-11-05
      • 2011-07-24
      • 1970-01-01
      • 2020-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多