다운로드 할 수있는 콘텐츠가있는 경우 GCM - Google 클라우드 메시징을 통해 Android 클라이언트에 알리는 웹 응용 프로그램 (PHP 용 GAE 사용)을 개발 중입니다. 응용 프로그램을 배포 할 때 올바르게GAE, PHP 및 GCM : 스트림을 열지 못했습니다. HTTP 요청이 실패했습니다! HTTP/1.0 405 메서드가 허용되지 않습니다.
이$json = array(
'data' => array(...),
'registration_ids' => array(...)
);
$data = json_encode($json);
$context = array(
'http' => array(
'method' => 'post',
'header' => 'Authorization: key=MY_SECRET_KEY' . "\r\n" .
'Content-Type: application/json' . "\r\n",
'content' => $data
)
);
$context = @stream_context_create($context);
$result = @file_get_contents("https://android.googleapis.com/gcm/send", false, $context);
위의 코드는 실행되지만 내 로컬 개발 환경에서 실행하지 않는 경우 :
다음 PHP 스크립트는 작업을해야한다.
로컬 개발 환경에서 $result
은 null
이고 file_get_contents
은 다음 경고 failed to open stream: HTTP request failed! HTTP/1.0 405 Method Not Allowed
을 "에코"합니다.