Note that there are some explanatory texts on larger screens.

plurals
  1. POReddit API in php returns bad captcha for submitting story
    text
    copied!<p>Using php for Reddit api for submitting a story returns bad captcha as error. I am able to login using the api and get usermod and captcha perfectly using api. Ideally if the reddit_session cookie is passed it should post and not return bad captcha can someone shed me some light on this..</p> <p>reference link: <a href="https://github.com/reddit/reddit/wiki/API">https://github.com/reddit/reddit/wiki/API</a></p> <pre><code>&lt;?php $user = ""; $passwd = ""; $url = "http://www.reddit.com/api/login/".$user; $r = new HttpRequest($url, HttpRequest::METH_POST); $r-&gt;addPostFields(array('api_type' =&gt; 'json', 'user' =&gt; $user, 'passwd' =&gt; $passwd)); try { $send = $r-&gt;send(); $userinfo = $send-&gt;getBody(); } catch (HttpException $ex) { echo $ex; } $arr = json_decode($userinfo,true); $modhash = $arr['json']['data']['modhash']; $reddit_session = $arr['json']['data']['cookie']; $post = array('uh'=&gt;$modhash, 'kind'=&gt;'link', 'url'=&gt;'yourlink.com', 'sr'=&gt;'funny', 'title'=&gt;'omog-asdfasf', 'id'=&gt;'newlink', 'r'=&gt;'funnyier', 'renderstyle'=&gt; 'html' ); $url = "http://www.reddit.com/api/submit"; // Upvote RoboHobo's comment :) // Add user cookie data $r-&gt;addCookies(array("reddit_session" =&gt; $reddit_session)); // Set URL to vote $r-&gt;setUrl($url); // Add vote information, found at http://wiki.github.com/talklittle/reddit-is-fun/api-all-functions $r-&gt;setPostFields($post); // Send request blindly try { $userinfo = $r-&gt;send(); } catch (HttpException $ex) { echo $ex; } pre($userinfo); exit; function pre($r){ echo "&lt;pre /&gt;"; print_r($r); } ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload