마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

GCM push하는데 couldn't connect to host 가 나오네요

0 추천

php와 연동으로 gcm을 구현하고 있는데

 

$registration_id = "디바이스 regstration_id";
$auth = "apikey";
$message = "TEST MESSAGE";

$headers = array
(
 'Content-Type:application/json',
 'Authorization:key='.$auth
);


$arr   = array();
$arr['data'] = array();
$arr['data']['msg'] = "TEST MESSAGE"; 
$arr['registration_ids'] = array();
$arr['registration_ids'][0] = $registration_id;


$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,    'https://android.googleapis.com/gcm/send');
curl_setopt($ch, CURLOPT_TIMEOUT,  10);
curl_setopt($ch, CURLOPT_HTTPHEADER,  $headers);
curl_setopt($ch, CURLOPT_POST,    true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($arr));
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); 
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); 

$response = curl_exec($ch);
if($response === FALSE)
{
	die('Curl failed: ' .curl_error($ch));
}
curl_close($ch);

echo $response;

이렇게 두고 url로 접근해서 push 메세지가 오는자 확인해보려던 중인데 브라우저에 Curl failed: couldn't connect to host 만 찍히네요 이런 접근 방식이 잘못된건가요 아니면 뭔가 코드상에 문제가 있는건가요?

php는 전혀 몰라서 골치아프네요

NarciS (280 포인트) 님이 2013년 5월 13일 질문

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...