1
私は2つのサーバー(たとえば、server1とserver2)を持っています。 server1にログインパネルがあり、server1を使用してログインすると、server2にリダイレクトする必要があります。この使用してPHPを実装するにはどうすればよい別のサーバーからログインした後にサーバーにリダイレクト
Sample Curl request
curl -X POST -H "user_name: aaa" -H "auth_type: email" -H "app_key: someapikey" -H "platform: Android_MDA" -H "password: 123456" -H "Cache-Control: no-cache" -H "Content-Type: application/x-www-form-urlencoded" -d '' "here is server1 login url"
:ここ
は、私が持っているカールコードです。私が手
Here is what I had done so far:
<?php
$post_fields = '{"login": "aaa", "password": "123456"}';
$cookie_file = tempnam('/temp', 'cookie');
$ch = curl_init('here is server1 login url');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_exec($ch);
// Execute request and read response
$response = curl_exec($ch);
// Check errors
if ($response) {
echo $response . "\n";
} else {
$error = curl_error($ch). '(' .curl_errno($ch). ')';
echo $error . "\n";
}
// Close connection
curl_close($ch);
?>
応答: は、(使用してすなわちURL IAM)をSERVER1への接続に失敗しました:接続が定義されていない(7)
まだ同じ応答@enRaiser – Aashi
コードを再度更新することはできますか。上記の変更と一緒に。リストの誰かが新鮮に始めることができるようにします。 – enRaiser