私は、私たちを訪問して私たちのウェブサイトに登録するユーザーがいくつかの機会を見ることができるように、セカンダリウェブサイトにアカウントを持つ登録システムを作ろうとしています。
だからここに行く:ウェブサイトは私がフォームを投稿して登録したかったのです
これまでの私のコード
<?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で作成しました。だから私はその情報を投稿するために作ることができるはずだと思います。他に提案がある場合。
この場合、サーバーは成功として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);
?>
https経由で接続しています。したがって、次の行を追加する必要があります。
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
私はあなたのコードをテストしました、そして、ウェブサイトは「間違ったユーザー名/パスワード」と答えました。これは、カールが正しく接続されていることを意味します。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加