Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. $pem_file = 'public/assets/pem/CannabisDispensaryDistribution.pem';
  2. $pem_secret = '';
  3. $apns_topic = 'com.dispensary.cannabis';
  4. if(defined('CURL_HTTP_VERSION_2_0'))
  5. {
  6. $devicetoken=['54688ae0e1ecc3bc0d517521f4935c014342ecca792ef798f0e63652a4620ed4','de963dfbc03f5de416c7d806e04a6f3276716f246942fa2a61cffa393a780120','a08832de8b72567aa487beefe50e4e29caaa4a51ab14706fc8f0ef9df1f6b9c4','48335901c12bf02a03cef453d2e7739eaac9779991cafef3fa70ffe587ea3f12'];
  7.  
  8. $sample_alert = '{"aps":{"alert":"hi","sound":"default"}}';
  9. foreach($devicetoken as $device_token)
  10. {
  11. $url = "https://api.development.push.apple.com/3/device/$device_token";
  12.  
  13. $ch = curl_init($url);
  14. curl_setopt($ch, CURLOPT_POSTFIELDS, $sample_alert);
  15. curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
  16. curl_setopt($ch, CURLOPT_HTTPHEADER, array("apns-topic: $apns_topic"));
  17. curl_setopt($ch, CURLOPT_SSLCERT, $pem_file);
  18. curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $pem_secret);
  19. $response = curl_exec($ch);
  20. $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  21.  
  22. //On successful response you should get true in the response and a status code of 200
  23. var_dump($response);echo "----";var_dump($httpcode);
  24. }
  25. }
  26. else{
  27. echo"NOt a supported version";
  28. }
  29.  
  30. �@@uUnexpected HTTP/1.x request: POST /3/device/54688ae0e1ecc3bc0d517521f4935c014342ecca792ef798f0e63652a4620ed4 bool(true) ----int(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement