I'm working on an app that allows users to create an account on reddit (and more). I use cURL and PHP to interface with the Reddit API, this is my 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, all I receive from the Reddit servers is 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 what that HTTP response means and I'm really confused on how to fix this. cURL runs perfectly fine on my server (I have tested it).
Any ideas?