구글 푸쉬 FCM이 서버에서 안되는데...

구글 푸쉬 FCM이 서버에서 안되는데...

QA

구글 푸쉬 FCM이 서버에서 안되는데...

답변 2

본문

서버상에서 체크해야할 부분이 뭐가 있을까요?

cafe24에선 동일한 소스로 되는데

제가 하고 있는 서버에선 안되더라구요.

 

php버전은 5.5이고

curl상황은 아래 이미지와 같습니다.

 

혹시 안드로이드 푸쉬가 안되는 부분이 있을까요?

 

fcm 소스는 아래와 같습니다.

/********************* 소스 **********************/

function sendPushNotification($tokens, $message) {

   ignore_user_abort();
   //ob_start();

   $url = 'https://fcm.googleapis.com/fcm/send';

   $fields = array(
     'to' => $tokens,
     'data' => array("message" =>$message)
   );

   define('GOOGLE_API_KEY', 'aaa')

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

   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, $url);
   curl_setopt($ch, CURLOPT_POST, true);
   curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
   curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));

   $result = curl_exec($ch);
   echo $result;
   /*
   if($result === false)
      die('Curl failed ' . curl_error());

   curl_close($ch);
   return $result;
   ob_flush();
   */
}

이 질문에 댓글 쓰기 :

답변 2

curl 뿐만 아리나 json도 설치하고 설정하셔야 합니다.

 define('GOOGLE_API_KEY', 'aaa') 끝에  세미콜론도 빠져 있네요.

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 5
© SIRSOFT
현재 페이지 제일 처음으로