iphone - push notification provider built in php -


"itemprop =" text ">

I downloaded a php code for Apple Push Notification in the beginning from the Internet This is the job when I have to do the Device token value Assigned direct variable, but when it did not work, I edit this php code to take the token values ​​from the device database MySQL:

  ; $ message, 'sound' = 'gt;' default '); // Encrypt payload as JSON $ payload = json_encode ($ body); //////////////////////////////////////////////// //////////////////// Make a global array $ x = array (); Function selectfromdb () {$ con = mysql_connect ("localhost", "root", "root"); Mysql_select_db ("my_db", $ Conn); Mysql_query ("set character_set_server = 'utf8'"); Mysql_query ("Set name 'utf8'"); $ Result = mysql_query ("select from iidid"); $ C = 0; While ($ r = mysql_fetch_array ($ result)) {$ x [$ c] = $ r ['idip']; $ C ++; }} //////////////////////////////////////////// // ///////////////////// selectfromdb (); $ I = 0; While creating ($ i & lt; sizeof ($ x)) // // Binary Notification $ msg = chr (0). Pack ('n', 32) pack ('h *', $ x [$ i]) pack ('n', strollon ($ payload)). $ Payload; // Send it to server $ result = fwrite ($ fp, $ msg, strlen ($ msg)); If (! $ Results) 'message has not been delivered & lt; / Br & gt; . PHP_EOL; Else 'message successfully delivered message & lt; / Br & gt; . PHP_EOL; $ I ++; } Echo 'end & lt; / Br & gt; '; // Close the server fclose ($ fp) connection; ? & Gt;   

Output: APNS end-connected

It seems that You need to add

global $ x; You select fromdb function maybe it would be better to return a value.

  function selectfromdb () {$ x = array (); $ Con = mysql_connect ("localhost", "root", "root"); Mysql_select_db ("my_db", $ Conn); Mysql_query ("set character_set_server = 'utf8'"); Mysql_query ("Set name 'utf8'"); $ Result = mysql_query ("select from iidid"); $ C = 0; While ($ r = mysql_fetch_array ($ result)) {$ x [$ c] = $ r ['idip']; $ C ++; } Return $ X; }    

Comments