简体   繁体   English

使用流星从stackoverflow获取用户数据

[英]Get user data from stackoverflow using meteor

I'm trying to develop a meteor application and in that i want to get the data of a user from stackoverlow. 我正在尝试开发一个流星应用程序,并且我想从stackoverlow获取用户的数据。

Suppose, My username is 假设我的用户名是

https://stackoverflow.com/users/1934044/user1934044 https://stackoverflow.com/users/1934044/user1934044

When user enters this link in my textbox i want to get the info about this user 当用户在我的文本框中输入此链接时,我想获取有关该用户的信息

For this, Do we need to register an application in stack apps or we can directly get the data from stackexchange api. 为此,我们是否需要在堆栈应用程序中注册应用程序,还是可以直接从stackexchange api获取数据?

I'm not using the stackexchange login system(OAUTH) in my app. 我没有在我的应用程序中使用stackexchange登录系统(OAUTH)。

If we can directly get the data, how to do it 如果我们可以直接获取数据,该怎么办

Can someont point me to the tutorial 可以给我指出本教程吗

You can get User Details by user ID with following methods endpoint : 您可以使用以下方法端点通过用户ID获取用户详细信息:

  • /users/{ids} / users / {ids}

For more details, Refer below Stack Exchange Document 有关更多详细信息,请参阅下面的Stack Exchange文档

https://api.stackexchange.com/docs/users-by-ids https://api.stackexchange.com/docs/users-by-ids

Or 要么

I have written Java Wrapper over Stack Exchange API. 我已经通过Stack Exchange API编写了Java Wrapper。

You can try it out. 您可以尝试一下。 https://github.com/sanjivsingh/stackoverflow-java-sdk https://github.com/sanjivsingh/stackoverflow-java-sdk

Sample code : 样例代码

StackExchangeApiQueryFactory queryFactory  = StackExchangeApiQueryFactory.newInstance();
System.out.println("get user by Id");
PagedList<User> users = queryFactory.newUserApiQuery()
        .withUserIds(1934044).listUserByIds();

Coming back to your question : 回到您的问题:

  • You need not register application for that. 您无需为此注册应用程序。

  • This method will work without any applicationKey and accessToken 此方法无需任何applicationKey和accessToken即可工作

You can use the Meteor Http package for this to call the api and get the data as json object. 您可以为此使用Meteor Http包来调用api并将数据作为json对象获取。

Eg: 例如:

On server, 在服务器上,

return Meteor.methods({

    getUserData: function (user_id) {
        var url =   "give the api url"+user_id;
        this.unblock();
        return Meteor.http.get(url);
    }

});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM