일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- 와일드카드
- java
- javascript
- ajax
- php
- DB
- File
- html
- junit
- tomcat
- larravel
- 안드로이드
- Linux
- NetBeans
- 톰캣
- 이클립스
- Spring
- jquery
- input
- laravel
- CentOS
- properties
- error
- JSON
- Android
- SeLinux
- 리눅스
- 정규식
- curl
- MySQL
- Today
- Total
합쭈기 programming
GCM 서비스 사용하기 본문
[php sample]
<!--?php
$registration_idPhone = {Token};
$auth = {Project key};
sendMessage($auth, $registration_idPhone);
function sendMessage($auth, $registration_id) {
$data = array(
'registration_ids' =------> array($registration_id),
'data' => array('data1' => 'yes', 'data2' => 'no')
);
$headers = array(
"Content-Type:application/json",
"Authorization:key=".$auth
);
print("<xmp>");
print(json_encode($data));
print("\n");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://android.googleapis.com/gcm/send");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$result = curl_exec($ch);
print_r($result);
curl_close($ch);
}
?>
'PHP' 카테고리의 다른 글
[PHP] cUrl 사용 시 couldn't connect host (0) | 2016.01.28 |
---|---|
[PHP] cUrl permission 문제 (0) | 2015.12.03 |
[PHP] 이미지 태그 제거 (0) | 2015.11.20 |
[PHP] 정규식으로 전화번호 하이픈(-) 넣기 (0) | 2015.11.13 |
[NetBeans] 단축키 (0) | 2015.10.01 |