Php Reddit API和cURL创建帐户时出现问题

Php Reddit API和cURL创建帐户时出现问题,php,api,http,curl,reddit,Php,Api,Http,Curl,Reddit,我正在开发一款允许用户在reddit(以及更多)上创建帐户的应用程序。我使用cURL和PHP与Reddit API进行接口,以下是我的代码: function create_account($username, $password, $captcha_iden, $captcha_answer){ $url = "http://reddit.com/api/register"; $ch = curl_init(); curl_setopt($ch, CURLO

我正在开发一款允许用户在reddit(以及更多)上创建帐户的应用程序。我使用cURL和PHP与Reddit API进行接口,以下是我的代码:

    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);


}
但是,我从Reddit服务器收到的信息是:

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
我不完全确定HTTP响应意味着什么,我真的很困惑如何解决这个问题。cURL在我的服务器上运行得非常好(我已经测试过了)


有什么想法吗?

回答的第一部分是将您从
reddit.com
切换到
www.reddit.com
。我假设第二个请求正在生成GET,该端点不接受GET(根据文档,只有POST),因此它返回404。尝试更新原始URL以包含
www.
并查看是否有效。

无耻插件:您还可以使用Runscope解决此类问题,并获得请求/响应的完整视图。谢谢!这就是问题所在。