i couldn't on reddit/r/redditdev i'm hoping fine folks @ stackoverflow can help
i'm trying call /api/submit.
- i can log user in , retrieve bearer/access token. (i use passport-reddit node module this)
- i can call /api/needs_captcha
- when /needs_captcha returns true, can call /api/new_captcha
- i can display captcha image user
now try call submit using nodejs' request module so
var options = { url: 'https://oauth.reddit.com/api/submit', method: 'post', headers: { 'authorization': 'bearer '+usertoken , 'user-agent': 'node.js' }, json: data } request(options, function(error, response, body) ...
a sample of "data" variable looks this:
{ api_type: 'json', kind: 'self', sr: 'test', title: 'more test', text: 'hello world', iden: 'o6nsdh4imcdb2to2deuxjagepkb4o7us', captcha: 'wzrtbl' } but back:
{ "jquery":[ [0, 1, "call", ["body"]], [1, 2, "attr", "find"], [2, 3, "call", [".status"]], [3, 4, "attr", "hide"], [4, 5, "call", []], [5, 6, "attr", "html"], [6, 7, "call", [""]], [7, 8, "attr", "end"], [8, 9, "call", []], [1, 10, "attr", "captcha"], [10, 11, "call", ["1owoohcicpcpdwjenw5krr2xhrl7j0as"]], [1, 12, "attr", "find"], [12, 13, "call", [".error.bad_captcha.field-captcha"]], [13, 14, "attr", "show"], [14, 15, "call", []], [15, 16, "attr", "text"], [16, 17, "call", ["care try these again?"]], [17, 18, "attr", "end"], [18, 19, "call", []] ] } also, tried running different user, 1 has enough karma points , didn't require captcha.
after posted, got response seems indicate success:
{ "jquery":[ [0, 1, "call", ["body"]], [1, 2, "attr", "find"], [2, 3, "call", [".status"]], [3, 4, "attr", "hide"], [4, 5, "call", []], [5, 6, "attr", "html"], [6, 7, "call", [""]], [7, 8, "attr", "end"], [8, 9, "call", []] ] } but can't find posted message in /r/test subreddit.
i must doing wrong entirely...
after going through different documentation related /api/submit, have discovered have missed field uh of sample of "data". missing of uh entails errors yours (look documentation below)
here more documentation related said:
https://github.com/reddit/reddit/wiki/api:-submit http://www.reddit.com/dev/api
Comments
Post a Comment