开发者

Trying to create a programmatic API for Reddit with Javascript

I work for a news company, and we want to be able to submit breaking news to reddit easily. I'm trying to create something that will login and post a link to reddit from just a url on our website.

Anyway, I am trying to use Javascript to click the buttons to login and I'm having problems.

Here's the button code right here:

<button class="btn" tabindex="4" type="submit">login</button>

which seems to submit this form:

<form class="login-form-side" onsubmit="return post_user(this, 'login');" action="http://www.reddit.com/post/login" id="log开发者_如何学运维in_login-main" method="post"><input type="hidden" value="login-main" name="op"><input type="text" tabindex="1" maxlength="20" name="user"><input type="password" tabindex="2" maxlength="20" name="passwd"><div style="display: none;" class="error WRONG_PASSWORD field-passwd">invalid password</div><span style="display:none" class="error RATELIMIT field-ratelimit"></span><span style="display: inline;" class="error RATELIMIT field-vdelay">you are doing that too much. try again in 1 minute.</span><div class="status error" style="display: none;"></div><div id="remember-me"><button tabindex="4" type="submit" class="btn">login</button><input type="checkbox" id="rem-login-main" tabindex="3" name="rem"><label for="rem-login-main">remember me</label><a href="/password" class="recover-password attention">recover password</a><div class="clear"></div></div></form>

Anyone have any idea how to do this?


Reddit has an extensively documented API that can be accessed with POST and GET requests. Also, is there any reason you're using JS to manipulate the DOM? You could use one of the wrappers instead of manually changing the HTML DOM.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜