Posts

Post not yet marked as solved
1 Replies
<?PHP if ( defined("CURL_VERSION_HTTP2") && (curl_version()["features"] & CURL_VERSION_HTTP2) !== 0) { $entityBody = file_get_contents('php://input'); $jsonConvet = json_decode($entityBody,true); $device_token = $jsonConvet["devicetoken"]; $ch = curl_init(); $body ['aps'] = array ( "alert" => array ( "status" => 1, "title" => "source:123,destination:456", "body" => "source:123,destination:456", ), "badge" => 1 , "sound" => "default" ); $curlconfig = array( CURLOPT_URL => "https://api.development.push.apple.com/3/device/" . $device_token, CURLOPT_RETURNTRANSFER =>true, CURLOPT_POSTFIELDS => json_encode($body), CURLOPT_SSLCERT =>"VOIP.pem", CURLOPT_SSLCERTPASSWD => "123456789", CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_2_0, CURLOPT_VERBOSE => true ); curl_setopt_array($ch, $curlconfig); $res = curl_exec($ch); if ($res === FALSE) { echo('Curl failed: ' . curl_error($ch)); } else{ echo('Curl success: ' . curl_error($ch)); } curl_close($ch); } else{ echo "No HTTP/2 support on client."; } ?>