2016-07-15 5 views
1

두 개의 서버 (예 : server1 및 server2)가 있습니다. server1에 로그인 패널이 있는데, server1을 사용하여 로그인하면 server2로 리디렉션해야합니다. 다른 서버에서 로그인 한 후 서버로 리디렉션

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" 

이 사용하는 PHP를 구현할 수있는 방법 :

여기에 내가 가지고있는 컬 코드입니다. 내가 할

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을 스피을) 서버 1에 연결하지 못했습니다 : 연결이 정의되지 않은 (7)

답변

0
  1. $의 post_body을 시간이 초과되었습니다.
  2. 당신은 cookie_file을 사용하고 있습니다 만, 컬링 케이스에서는 쿠키가 전송되지 않습니다. 그래서 목록에서 흔적과 같은 쿠키를 제거하십시오.
+0

여전히 동일한 응답 @enRaiser – Aashi

+0

코드를 다시 업데이트 할 수 있습니까? 위의 변경 사항과 함께. 그래서 목록에 누군가 다른 사람이 신선한 시작할 수 있습니다. – enRaiser

관련 문제