php - Issue with Reddit API and cURL creating an account -


i'm working on app allows users create account on reddit (and more). use curl , php interface reddit api, code:

    function create_account($username, $password, $captcha_iden, $captcha_answer){      $url = "http://reddit.com/api/register";      $ch = curl_init();     curl_setopt($ch, curlopt_url, $url);     curl_setopt($ch, curlopt_followlocation, 1);     curl_setopt($ch, curlopt_returntransfer, 1);     curl_setopt($ch, curlopt_header, 1);     curl_setopt($ch, curlopt_post, true);      $data = "user=$username&passwd=$password&passwd2=$password&rem=false&reason=redirect&api_type=json&iden=$captcha_iden&captcha=$captcha_answer";      curl_setopt($ch, curlopt_postfields, $data);      $curl_scraped_page = curl_exec($ch);      die($curl_scraped_page);     curl_close($ch);   } 

however, receive reddit servers this:

http/1.1 302 moved temporarily  server: akamaighost  content-length: 0  location: http://www.reddit.com/api/register  date: wed, 31 jul 2013 20:02:03 gmt  connection: keep-alive   http/1.1 404 not found  content-length: 0  content-type: text/html; charset=utf-8    server: '; drop table servertypes; --  vary: accept-encoding  date: wed, 31 jul 2013 20:02:04 gmt  connection: keep-alive 

i'm not entirely sure http response means , i'm confused on how fix this. curl runs fine on server (i have tested it).

any ideas?

the first part of response switching on reddit.com www.reddit.com. i'm assuming second request making get, not accepted endpoint (only post according docs) , returns 404. try updating original url include www. , see if works.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -