Posts

Post not yet marked as solved
1 Replies
2.5k Views
I am using PHP to send notifications from my server.But it is not working, the program outputs "Unexpected HTTP/1.x request: GET /3/device/myDeviceToken" upon calling curl_exec().No notification is received on my iOS device either.This is the code:token = getToken($keyfile, $kid, $iss); $url="https://api.development.push.apple.com:443/3/device/".urlencode($to); $curl = curl_init(); $headers = array("Content-Type:application/json", "authorization: bearer ".$token, "apns-expiration: 0", "apns-priority: 10", "apns-topic: balintfodor.locationconnection-test"); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HEADER, true); $options = array($curl, array( CURLOPT_PORT => 443, CURLOPT_HTTPHEADER => $headers, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $data, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_TIMEOUT => 30, CURLOPT_SSL_VERIFYPEER => FALSE, CURLOPT_HEADER => 1, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_2_0 )); $result = curl_exec($curl); $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); $err = curl_error($curl); var_dump($httpcode, $result, $err); //int(0) bool(true) string(0) ""
Posted Last updated
.