2016-08-15 11 views
0

私は、私たちを訪問して私たちのウェブサイトに登録するユーザーが、ある機会を見ることができるようにセカンダリWebサイトにアカウントを持っている登録システムを作ろうとしています。PHP(POST)を使用してcURLを使用した完全なフォーム

だからここには行く: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の上と同じで、フォームに記入することができるようにしたいユーザーとしてCURL、あるいはJSとAJAXを使ってドメインBにアカウントを持っています。

これを達成するための解決策がある場合は、私に教えてください:)あなたはウェブサイトでも見ていることができます。

ありがとうございました!

後期編集

Postman POST account

I`veはPOSTMANにこれを作りました。だから私はその情報を投稿するためにできるはずだと思う。あなたは他の提案がある場合。

この場合、サーバはエラーとして成功として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

ところで、私は、* https://auth.aiesec.org/users*には* https://auth.aiesecではなく、登録のためにPOSTSフォームを考えます。 org/users/sign_in * – Bobface

+0

この/ usersへのリンクを変更する必要があります。しかし、そのリンクのメッセージはこれです - あなたが探していたページは存在しません。 アドレスが誤って入力されているか、ページが移動している可能性があります.-- – Daniel

関連する問題