php push notification for android and ios using api parse


php push notification for android and ios using api parse.This code worked for me on server.

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$APPLICATION_ID = " ";
$REST_API_KEY = " ";

$url = 'https://api.parse.com/1/push';

$data = array(
    'where' => '{}',
    'expiry' => 1451606400,
    'data' => array(
        'alert' => 'Test Push',
        'sound' => 'push.caf',
    ),
);
$_data = json_encode($data);
$headers = array(
    'X-Parse-Application-Id: ' . $APPLICATION_ID,
    'X-Parse-REST-API-Key: ' . $REST_API_KEY,
    'Content-Type: application/json',
    'Content-Length: ' . strlen($_data),
);

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
//curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 
//curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
      $response = curl_exec($curl);

  var_dump($response); 
?>


Advertisements
About

myself pramodh kumar yet another php developer from India and have worked on oops,procedural,yii framework,codeigniter,wordpress,joomla,api and more.

Tagged with: , , , , , , ,
Posted in push notification
2 comments on “php push notification for android and ios using api parse
  1. sweetychinnu says:

    Where to pass device id ?
    how do i ssend message to particular device ?

    Like

  2. vijaydhas chandran says:

    Hi.. I am also having the same issue. How to send the message to particular mobile?

    Like

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow php tutorial on WordPress.com
categories
Calendar
March 2014
M T W T F S S
« Feb   Apr »
 12
3456789
10111213141516
17181920212223
24252627282930
31  
Follow me on Twitter
Blog Stats
  • 73,741 hits
%d bloggers like this: