标签: stackexchange-api

带有 Stack Overflow API 标签的问题列表

正如你们中的一些人所知,Stack Overflow 现在有一个 API,它现在使这些类型的问题成为有效的编程问题。

我的问题:我正在尝试编写一个小脚本来连接到 Stack Overflow API,以获取某个主题(例如 oauth、Python、twitter-api 等)下的所有问题的列表。

有人可以建议如何做到这一点吗?我没有使用 API 的经验,欢迎提供代码或教程链接。我正在使用 PHP。

php api stackexchange-api

6
推荐指数
1
解决办法
1313
查看次数

使用StackOverflow API检索JSON

我想使用API​​从我的Stack Overflow配置文件中检索信息作为JSON.

所以我使用这个链接http:/api.stackoverflow.com/1.0/users/401025/.

但是当我发出请求时,我得到一个包含JSON数据的文件.如何使用Ajax处理该文件?

这是我的代码(http://jsfiddle.net/hJhfU/2/):

<html>
 <head>
  <script>
   var req;

   getReputation();

   function getReputation(){
      req = new XMLHttpRequest();
      req.open('GET', 'http://api.stackoverflow.com/1.0/users/401025/');
      req.onreadystatechange = processUser;
      req.send();
   }

   function processUser(){       
       var res = JSON.parse(req.responseText);
       alert('test');      
   }
  </script>
 </head>
Run Code Online (Sandbox Code Playgroud)

警报永远不会被触发,req.responseText似乎是空的.有任何想法吗?

javascript ajax stackexchange-api

6
推荐指数
1
解决办法
1965
查看次数

stackoverflow搜索api

我想使用stackoverflow API的搜索方法返回基于搜索关键字的结果的json结构,然后在SearchResults div中显示这些结果(标题,描述和url).

我是C#的新手,我的第一次尝试是这样的:

    protected void searchStockOverflow(string y)
    {

        var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://api.stackoverflow.com/1.1/search?intitle="+y);
        httpWebRequest.ContentType = "text/json";
        httpWebRequest.Method = "POST";

        using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
        {
            string json = "{ \"intitle\": \"" + y + "\"}";

            streamWriter.Write(json);
        }
        var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
        using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
        {
            var responseText = streamReader.ReadToEnd();

            SearchResults.InnerHtml += "<div style='border:1px solid blue;margin:5px;'>";
            SearchResults.InnerHtml += responseText + "<br />";
            SearchResults.InnerHtml += "</div><br style='clear:both;' />";
        }
    }
Run Code Online (Sandbox Code Playgroud)

问题是返回的东西看起来像dingbats垃圾 - 我猜是因为它是序列化的,需要反序列化?

c# json stackexchange-api

6
推荐指数
1
解决办法
2698
查看次数

Stackoverflow API响应格式

当C#创建HTTP GET请求时,Stackoverflow API返回意外响应.

如果我将http://api.stackoverflow.com/1.1/users/882993粘贴到浏览器地址栏中,我会得到正确的JSON响应:

{
  "total": 1,
  "page": 1,
  "pagesize": 30,
  "users": [
    {
      "user_id": 882993,
      "user_type": "registered",
      "creation_date": 1312739131,
      "display_name": "Jack",
      "reputation": 1926,
      "email_hash": "69243d90e50d9e0b3e025517fd23d1da",
      "age": 23,
      "last_access_date": 1358087009,
      "website_url": "http://jtbrown.me.uk",
      "location": "Birmingham, United Kingdom",
      "about_me": "<p>Student.</p>\n",
      "question_count": 68,
      "answer_count": 79,
      "view_count": 115,
      "up_vote_count": 98,
      "down_vote_count": 3,
      "accept_rate": 94,
      "association_id": "d64187a3-bf66-4a4d-8e87-6ef18f0397e3",
      "user_questions_url": "/users/882993/questions",
      "user_answers_url": "/users/882993/answers",
      "user_favorites_url": "/users/882993/favorites",
      "user_tags_url": "/users/882993/tags",
      "user_badges_url": "/users/882993/badges",
      "user_timeline_url": "/users/882993/timeline",
      "user_mentioned_url": "/users/882993/mentioned",
      "user_comments_url": "/users/882993/comments",
      "user_reputation_url": "/users/882993/reputation",
      "badge_counts": {
        "gold": 0,
        "silver": 7,
        "bronze": 34 …
Run Code Online (Sandbox Code Playgroud)

c# asp.net stackexchange-api

6
推荐指数
1
解决办法
340
查看次数

从StackOverflow API请求JSON的编码问题

我无法想象我的生活.下面是请求模块的实现,但我也尝试使用node-XMLHttpRequest模块无济于事.

var request = require('request');

var url = 'http://api.stackexchange.com/2.1/questions?pagesize=100&fromdate=1356998400&todate=1359676800&order=desc&min=0&sort=votes&tagged=javascript&site=stackoverflow';

request.get({ url: url }, function(error, response, body) {
    if (error || response.statusCode !== 200) {
        console.log('There was a problem with the request');
        return;
    }

    console.log(body); // outputs gibberish characters like ?
    console.log(body.toString()); // also outputs gibberish
});
Run Code Online (Sandbox Code Playgroud)

似乎是一个编码问题,但我在浏览器中使用了完全相同的代码(使用本机XHR对象),它没有问题.我究竟做错了什么?

compression gzip node.js stackexchange-api

6
推荐指数
2
解决办法
767
查看次数

在网站中显示Stackoverflow评级/信誉/徽章

在Stackoverfow获得声誉是一项艰苦的工作,如果我能在我的网站上获得声誉,我会感到高兴.可能吗?

stackoverflow是否会针对用户公开任何API?

[UPDATE]

当我输入时

http://api.stackoverflow.com/1.1/users/ {user-id} /

它给了我一个JSON数据,这对我来说似乎很好.可以这样使用它吗?

stackapps.com得到它回复Nathan Osman

谢谢.

stackexchange-api

6
推荐指数
1
解决办法
467
查看次数

Stackoverflow声誉

我试图在我的项目中显示用户的Stack Overflow信誉.我有用户电子邮件.因此,使用用户电子邮件作为输入,我可以获得用户的Stack Overflow声誉吗?

现在我尝试使用Javascript SDK.使用Stack Overflow的身份验证方法.在这种情况下,用户必须登录到Stack Overflow,然后我获得了用户的Stack Overflow id和声誉.

  1. 我是否可以获得未经身份验证通过其emailid的用户的Stack Overflow声誉?
  2. 每当他在Stack Overflow中改变他的声誉时,我是否有选择在我的网站中自动更新他的Stack Overflow声誉值?

stackexchange-api

6
推荐指数
2
解决办法
1795
查看次数

如何使用 Stack Exchange API 获取答案的正文?

我正在使用StackAPI来获取投票最多的问题以及这些问题的投票最多的答案:-

from stackapi import StackAPI
SITE = StackAPI('stackoverflow')
SITE.max_pages=1
SITE.page_size=10

questions = SITE.fetch('questions', min=20, tagged='python', sort='votes')
for quest in questions['items']:
    if 'title' not in quest or quest['is_answered'] == False:
        continue
    title = quest['title']
    print('Question :- {0}'.format(title))
    question_id = quest['question_id']
    print('Question ID :- {0}'.format(question_id))
    top_answer = SITE.fetch('questions/' + str(question_id) + '/answers', order = 'desc', sort='votes')
    print('Most Voted Answer ID :- {0}'.format(top_answer['items'][0]['answer_id']))
Run Code Online (Sandbox Code Playgroud)

现在使用这个answer_id我想得到答案的正文。我可以使用此 API 链接获取其余详细信息。

python python-3.x stackexchange-api

5
推荐指数
1
解决办法
2542
查看次数

通过 API 访问 Stack Exchange 用户的“about_me”数据?

我正在尝试about_me通过 Stack Overflow 提供的 API获取Stack Exchange 配置文件上的数据:https : //api.stackexchange.com/docs/users-by-ids

示例:https :
    //api.stackexchange.com/2.2/users/3029?&site=bitcoin

API 不会返回about_me配置文件描述。
一个人如何获得这个?

stackexchange-api

5
推荐指数
1
解决办法
148
查看次数

Stack Exchange API 获取影响/达到的人数

我搜索了Stack Exchange API v2.2的整个文档,但找不到任何 API 来获取有关用户页面上影响部分的数据。

我对特定用户的影响/达到的人数数据感兴趣。

解决此问题的一种方法是GET通过使用 URL:https://stackoverflow.com/users/${id}并使用document.getElementById(),获取所需数据的整个用户页面。

但问题是,获取整个用户页面是庞大的,而不是最佳解决方案。

stackexchange stackexchange-api

5
推荐指数
1
解决办法
97
查看次数