【问题标题】:How to get KIK profile details by username, using the URL?如何使用 URL 通过用户名获取 KIK 个人资料详细信息?
【发布时间】:2016-10-13 19:36:20
【问题描述】:

我想使用 KIK URL 获取用户个人资料详细信息..

例如,http://xyz-some-kik-domain/user/[username]

【问题讨论】:

    标签: api kik


    【解决方案1】:

    如果你使用kik-python,有一个方法kik.get_userhttps://kik.readthedocs.io/en/latest/user.html#users

    如果您不使用它,只需向下面的 url 发出 GET 请求

        response = requests.get(
            'https://api.kik.com/v1/user/<username>',
            auth=('<bot_username>', '<bot_api_key>'),
        )
    

    【讨论】:

    • 如何获取 bot_api_key?我在 KIK 应用中创建了一个机器人。
    • 另外,我想从世界各地的任何用户名中获取用户详细信息,而不仅限于我的机器人帐户。
    • bot api_key 是 dev.kik.com 的配置选项卡上列出的 api_key
    • 您无法访问未向您的机器人发送消息的人的用户名。
    【解决方案2】:

    这是无需机器人 API 密钥即可获取用户详细信息的 kik API。

    https://ws2.kik.com/user/KikTeam

    我自己编写了一个简单的 java 方法,通过解析 JSON 响应来获取信息。

    public static void getInformation(String username){
        String API = "https://ws2.kik.com/user/";
    
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(API + username).openConnection().getInputStream(), StandardCharsets.UTF_8))) {
            String response = reader.lines().collect(Collectors.joining("\n"));
            JSONObject jsonObject = new JSONObject(response);
            String firstName = jsonObject.getString("firstName");
            String lastName = jsonObject.getString("lastName");
            long displayPicLastModified = jsonObject.getLong("displayPicLastModified");
            String displayPic = jsonObject.getString("displayPic");
            System.out.printf("firstName: %s, lastName: %s, displayPicLastModified: %d, displayPic: %s\n",
                    firstName, lastName, displayPicLastModified, displayPic);
        } catch (IOException | JSONException e) {
            e.printStackTrace();
        }
    }
    

    现在让我们使用

    来调用它
    getInformation("KikTeam");
    

    就这么简单。

    【讨论】:

      猜你喜欢
      • 2011-01-13
      • 2016-04-10
      • 2017-10-07
      • 1970-01-01
      • 2019-02-08
      • 1970-01-01
      • 2013-07-02
      • 1970-01-01
      • 2021-05-30
      相关资源
      最近更新 更多