質問編集履歴
3
情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -97,3 +97,177 @@
|
|
97
97
|
```
|
98
98
|
|
99
99
|
となるので、ファイルパスは正しいかと思います。
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
2016/04/20 追記
|
104
|
+
|
105
|
+
「pushTest.php」の内容は以下になります。
|
106
|
+
|
107
|
+
「server_certificates_sandbox.pem」と「entrust_root_certification_authority.pem」はpushTest.phpと同じ階層にあります。
|
108
|
+
|
109
|
+
```php
|
110
|
+
|
111
|
+
<?php
|
112
|
+
|
113
|
+
/**
|
114
|
+
|
115
|
+
* @file
|
116
|
+
|
117
|
+
* sample_push.php
|
118
|
+
|
119
|
+
*
|
120
|
+
|
121
|
+
* Push demo
|
122
|
+
|
123
|
+
*
|
124
|
+
|
125
|
+
* LICENSE
|
126
|
+
|
127
|
+
*
|
128
|
+
|
129
|
+
* This source file is subject to the new BSD license that is bundled
|
130
|
+
|
131
|
+
* with this package in the file LICENSE.txt.
|
132
|
+
|
133
|
+
* It is also available through the world-wide-web at this URL:
|
134
|
+
|
135
|
+
* http://code.google.com/p/apns-php/wiki/License
|
136
|
+
|
137
|
+
* If you did not receive a copy of the license and are unable to
|
138
|
+
|
139
|
+
* obtain it through the world-wide-web, please send an email
|
140
|
+
|
141
|
+
* to aldo.armiento@gmail.com so we can send you a copy immediately.
|
142
|
+
|
143
|
+
*
|
144
|
+
|
145
|
+
* @author (C) 2010 Aldo Armiento (aldo.armiento@gmail.com)
|
146
|
+
|
147
|
+
* @version $Id: sample_push.php 65 2010-12-13 18:38:39Z aldo.armiento $
|
148
|
+
|
149
|
+
*/
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
// Adjust to your timezone
|
154
|
+
|
155
|
+
date_default_timezone_set('Asia/Tokyo');
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
// Report all PHP errors
|
160
|
+
|
161
|
+
error_reporting(-1);
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
// Using Autoload all classes are loaded on-demand
|
166
|
+
|
167
|
+
require_once 'ApnsPHP/Autoload.php';
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
// Instanciate a new ApnsPHP_Push object
|
172
|
+
|
173
|
+
$push = new ApnsPHP_Push(
|
174
|
+
|
175
|
+
ApnsPHP_Abstract::ENVIRONMENT_SANDBOX,
|
176
|
+
|
177
|
+
'server_certificates_sandbox.pem'
|
178
|
+
|
179
|
+
);
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
// Set the Root Certificate Autority to verify the Apple remote peer
|
184
|
+
|
185
|
+
$push->setRootCertificationAuthority('entrust_root_certification_authority.pem');
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
// Connect to the Apple Push Notification Service
|
190
|
+
|
191
|
+
$push->connect();
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
// Instantiate a new Message with a single recipient
|
196
|
+
|
197
|
+
$message = new ApnsPHP_Message('72cb1ae4707aef1df5e72d6c714ce245925317f85aca21fd7fc070acb193b1c2');
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
// Set a custom identifier. To get back this identifier use the getCustomIdentifier() method
|
202
|
+
|
203
|
+
// over a ApnsPHP_Message object retrieved with the getErrors() message.
|
204
|
+
|
205
|
+
$message->setCustomIdentifier("Message-Badge-3");
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
// Set badge icon to "3"
|
210
|
+
|
211
|
+
$message->setBadge(3);
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
// Set a simple welcome text
|
216
|
+
|
217
|
+
$message->setText('Hello APNs-enabled device!');
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
// Play the default sound
|
222
|
+
|
223
|
+
$message->setSound();
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
// Set a custom property
|
228
|
+
|
229
|
+
$message->setCustomProperty('acme2', array('bang', 'whiz'));
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
// Set another custom property
|
234
|
+
|
235
|
+
$message->setCustomProperty('acme3', array('bing', 'bong'));
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
// Set the expiry value to 30 seconds
|
240
|
+
|
241
|
+
$message->setExpiry(30);
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
// Add the message to the message queue
|
246
|
+
|
247
|
+
$push->add($message);
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
// Send all messages in the message queue
|
252
|
+
|
253
|
+
$push->send();
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
// Disconnect from the Apple Push Notification Service
|
258
|
+
|
259
|
+
$push->disconnect();
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
// Examine the error message container
|
264
|
+
|
265
|
+
$aErrorQueue = $push->getErrors();
|
266
|
+
|
267
|
+
if (!empty($aErrorQueue)) {
|
268
|
+
|
269
|
+
var_dump($aErrorQueue);
|
270
|
+
|
271
|
+
}
|
272
|
+
|
273
|
+
```
|
2
情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -71,3 +71,29 @@
|
|
71
71
|
解決方法がわからず困っています。
|
72
72
|
|
73
73
|
よろしくお願い致します。
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
追加情報
|
78
|
+
|
79
|
+
pushTest.phpと同じディレクトリに入れています。
|
80
|
+
|
81
|
+
setRootCertificationAuthorityは以下の通りです。
|
82
|
+
|
83
|
+
```php
|
84
|
+
|
85
|
+
$push->setRootCertificationAuthority('entrust_root_certification_authority.pem');
|
86
|
+
|
87
|
+
```
|
88
|
+
|
89
|
+
仮にファイルパスが間違っていた場合,
|
90
|
+
|
91
|
+
```
|
92
|
+
|
93
|
+
$php pushTest.php
|
94
|
+
|
95
|
+
Fatal error: Uncaught exception 'ApnsPHP_Exception' with message 'Unable to read Certificate Authority file '../entrust_root_certification_authority.pem'' in ...
|
96
|
+
|
97
|
+
```
|
98
|
+
|
99
|
+
となるので、ファイルパスは正しいかと思います。
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -66,6 +66,8 @@
|
|
66
66
|
|
67
67
|
|
68
68
|
|
69
|
+
Push Notification用のSSL証明書を作り直せば良いとのブログも拝見したのですが、rubyではうまくいってるのでそうではないと思いますが...
|
70
|
+
|
69
71
|
解決方法がわからず困っています。
|
70
72
|
|
71
73
|
よろしくお願い致します。
|