2016-08-15 134 views
0

我正在尝试创建一个注册系统,其中访问我们并注册到我们网站的用户将在辅助网站上拥有一个帐户,以便他们能够看到一些机会。用cURL使用PHP(POST)完成表格

所以这里有云:The website were I want to POST the Form and Register

到目前为止我的代码

<?php 
    // set post fields 
    $post = [ 
    // this i don't master fell free to approach the subject for future reffrance 
    'authenticity_token'=>'vhmPffEAIiIbjo36K8CI77+YDQfMPBWEG8ymplsGJ0w=', 
    'user[email]'=>'[email protected]', 
    'user[first_name]'=>'test', 
    'user[last_name]'=>'test', 
    'user[password]'=>'12345678',//smart password (had to be 8char long) 
    'user[country]'=>'Country(placeholder)', 
    'user[mc]'=>'1560', //id of the country 
    'user[lc_input]'=>'1475', //id of the dropdown 
    'user[lc]'=>'1475',//id of the dropdown 
    'commit'=>'REGISTER',//value of submit 

    ]; 

    $ch = curl_init('https://auth.aiesec.org/users/sign_in'); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 

    // execute! 
    $response = curl_exec($ch); 

    // close the connection, release resources used 
    curl_close($ch); 

    // do anything you want with your response 
    var_dump($response); 
    ?> 

故事:

正如我希望能够完成对域A中的形式提供给用户,并在同一时间在域B上使用CURL甚至JS和AJAX有一个帐户。

如果您有任何解决方案来实现这一点,请让我知道:)你也可以看看网站。

谢谢!

后期编辑

Postman POST account

I`ve在邮差使这个。所以我认为我应该能够做出这个信息。如果你有其他建议。

在这种情况下,服务器返回500的成功和200错误(安全)

最终工作守则

<?php 

    // set post fields 
    $post = [ 
    // this i don`t master fell free to approach the subject for future reffrance 
    'authenticity_token'=>'NKWAg8mGA9gUueBaJ5Og+oEOC5O2rZarZzMK+GnjuCA=', 
    'user[email]'=>'', 
    'user[first_name]'=>'', 
    'user[last_name]'=>'', 
    'user[password]'=>'',//smart password (had to be 8char long) 
    'user[country]'=>'', 
    'user[mc]'=>'', //id of the country 
    'user[lc_input]'=>'', //id of the dropdown 
    'user[lc]'=>'',//id of the dropdown 
    'commit'=>'REGISTER',//value of submit 

    ]; 

    $ch = curl_init('https://auth.aiesec.org/users/'); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 


    // execute! 
    $response = curl_exec($ch); 

    // close the connection, release resources used 
    curl_close($ch); 

    // do anything you want with your response 
    var_dump($response); 


    ?> 
+0

你真正的问题是什么? – Ikari

+0

我只需要能够在另一个网站上创建一个帐户,当用户完成我的表格 – Daniel

回答

2

您是通过HTTPS 连接。所以你应该添加这些行:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 

我测试了你的代码,网站回应了“错误的用户名/密码”。这意味着卷曲正确连接。

+0

是。你是对的。如果您查看提供的链接https://opportunities.aiesec.org/programmes,我已经确定的一个问题是我将如何获得注册表格cuz。这意味着我必须点击登录/注册按钮 – Daniel

+0

顺便说一句,我认为形式POSTS到* https://auth.aiesec.org/users*注册,而不是* https://auth.aiesec。 org/users/sign_in * – Bobface

+0

所以我应该改变这个/用户的链接。但该链接上的信息是这样的 - 您正在寻找的页面不存在。 您可能错误输入了地址或页面可能已移动.-- – Daniel