Reddit 提交 API 500 错误 [英] Reddit submit API 500 error

查看:50
本文介绍了Reddit 提交 API 500 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 reddit API 发帖,但服务器返回 500 错误.

I'm attempting to use the reddit API to make posts, but the server is returning 500 errors.

例如,我尝试使用我的 cookie 集发布到此 URL:

For example, I tried posting to this URL with my cookie set:

http://www.reddit.com/api/submit?title=testtitle&sr=compsci&uh=<modhash_goes_here>&text=testtext&kind=self

我的 Chrome Dev Tools 打印出以下错误:

And my Chrome Dev Tools prints the following error:

POST <my long URL goes here> 500 (Internal Server Error)

我在 StackOverflow 上的某个地方读到你需要 modhash cookie,所以这就是我正在使用的.我尝试不使用 modhash,并尝试使用 Apigee 上列出的多余的r=subreddit"参数.都没有帮助.

I read somewhere on StackOverflow that you need both the modhash and the cookie, so that's what I'm using. I tried without the modhash, and I tried with the superfluous "r=subreddit" parameter listed on Apigee. Neither helped.

为什么我会收到 500 错误?

Why would I be getting a 500 error?

推荐答案

你不应该在 URL 中 POST 数据;你在 POST 对象中设置数据,然后 POST ......这是有道理的,因为你 POST 诸如密码之类的东西.例如(使用 jQuery):

You're not supposed to POST data in the URL; you set the data in the POST object, and the POST that.... Which makes sense, because you POST things like passwords. For example (using jQuery):

$.post('http://www.reddit.com/api/vote',
        {
          'id' : 't3_' + id,
          'dir': dir,
          'uh' : mod_hash
        },
        function(data) {
            var err = false;
            for (var i in data) {
                if (data.hasOwnProperty(i)) {
                    err = true;
                    break;
                }
            }

            // No error!
            callback(err);
        });

URL 恰好适用于一些 reddit API 调用,因为除了 POST 之外,它们还在 GET 上实现.

URLs just happen to work for some reddit API calls because they implemented them on GET in addition to POST.

这篇关于Reddit 提交 API 500 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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