2014-03-01 1 views
0

GAE 사이트에서 두 개의 PHP를 설정하려고합니다. 하나는 웹 서비스 레이어로 작동하고 다른 하나는 프런트 엔드로 작동합니다. 지금까지 상황은 훌륭합니다. 이 두 레이어 사이의 통신을 보호하려고 노력하고 있으므로 웹 서비스를 호출 할 수있을뿐만 아니라Google App Engine 용 PHP에서 URLFetch를 수행 할 때 리디렉션을 사용하지 않도록 설정하는 방법은 무엇입니까?

이 기사에서는 요청하는 방법에 대해 이야기했고, 그렇게함으로써 X-Appengine-Inbound-Appid 헤더를 설정할 수 있습니다. 이것은 정확히 내가 원하는 것입니다. https://developers.google.com/appengine/docs/php/urlfetch/#PHP_Making_requests

이 작업을 수행하려면 "UrlFetch 서비스를 호출 할 때 리디렉션을 따르지 않도록 알리는 것이 좋습니다."; 그러면 실제로 당신이 실제로 어떻게되었는지에 관한 어떠한 문서도 제공하지 않습니다. DO.

내 요청은 다음과 같습니다

$data = ['data' => 'this', 'data2' => 'that']; 
$data = http_build_query($data); 
$context = [ 
    'http' => [ 
    'method' => 'get', 
    'header' => "custom-header: custom-value\r\n" . "custom-header-two: custome-value-2\r\n", 
    'content' => $data, 
    ] 
]; 
$context = stream_context_create($context); 
$result = file_get_contents('urlgoeshere', false, $context); 

생각 & 도움 감사합니다!

답변

3

두 가지 방법으로, 0

$context = [ 
    'http' => [ 
    'method' => 'get', 
    'header' => "custom-header: custom-value\r\n" . "custom-header-two: custome-value-2\r\n", 
    'content' => $data, 
    'follow_location' => false, 
    ] 
]; 

또는

$context = [ 
    'http' => [ 
    'method' => 'get', 
    'header' => "custom-header: custom-value\r\n" . "custom-header-two: custome-value-2\r\n", 
    'content' => $data, 
    'max_redirects' => 0, 
    ] 
]; 
+0

나는이 시도하지만이 GAE에 어떤 영향을 미칠 것 같지 않았다 거짓 및/또는 max_redirects로 설정 follow_location 중 헤더. – dracolytch

+0

어떤 헤더를 사용하고 있습니까? –

+0

** X-Appengine-Inbound-Appid ** : 하나의 앱이 다른 앱을 호출 할 때 Google App Engine 헤더. 리디렉션을 해제해야합니다. Google [문서] (http://developers.google.com/appengine/docs/php/urlfetch/#PHP_Making_requests) : _ 다른 App Engine 앱에 요청하는 경우 UrlFetch 서비스에 리디렉션을 호출 할 때 리디렉션을 따르지 않습니다. 이 설정은 두 가지를 수행합니다 이 통화 빠르게 만든다 요청에 앱 ID를 포함하는 X-AppEngine에 - 인바운드 - APPID 헤더를 추가하므로 응답 응용 프로그램은 당신에게 그렇게 들어오는 requests._ – dracolytch

관련 문제