I've been trying to make it work all day and no luck. This is how far I got...
 <?php 
 $url = 'http://parse.verbomedia.com:1337/parse/push'; 
 $appId = '******'; 
 $masterKey = '******'; 
 $headers = array( 
 "Content-Type: application/json", 
 "X-Parse-Application-Id: " . $appId, 
 "X-Parse-Master-Key: " . $masterKey
 ); 
 $objectData = '{"where":{"deviceType":"ios"},"data":{"alert":"Hello, Parse!"}}'; 
 $rest = curl_init(); 
 curl_setopt($rest,CURLOPT_URL,$url); 
 curl_setopt($rest,CURLOPT_POST,1); 
 curl_setopt($rest,CURLOPT_POSTFIELDS,$objectData); 
 curl_setopt($rest,CURLOPT_HTTPHEADER,$headers); 
 curl_setopt($rest,CURLOPT_SSL_VERIFYPEER, false); 
 curl_setopt($rest,CURLOPT_RETURNTRANSFER, true); 
 $response = curl_exec($rest); 
 echo $response; 
 print_r($response); 
 curl_close($rest); 
 ?> 
It works fine through the Parse Dashboard.
Any ideas on what I might be doing wrong?
- 
 There's an ready to use library for php - why build your own?Philipp– Philipp2017年05月04日 23:08:12 +00:00Commented May 4, 2017 at 23:08
- 
 Hi @Philipp, I was looking at it just now, but I don't need the whole SDK just a simple way to deliver the push notifications.danrodrigues– danrodrigues2017年05月04日 23:28:25 +00:00Commented May 4, 2017 at 23:28
2 Answers 2
The php sdk currently supports client push via the ParsePush class. The following is pulled from an example in the README.md on the php sdk's github page.
// Push to Channels
ParsePush::send(array(
 "channels" => ["PHPFans"],
 "data" => $data
), true);
// note the master key is required via 'true'
You can find additional examples and explanations in the docs for this sdk as well.
Note that although the php sdk supports this you must first setup a working push configuration in your parse-server instance. Although the php sdk is good to go out of the box, the server won't be able to handle pushing out notifications via GCM or APNS without the proper setup in advance.
Comments
client push is not supported in parse-server (Read here) so in order to send push notifications you must do the following:
- Create a cloud code function that will leverage the parse js SDK. there you will need to write some lines of code to send the push to the specific client (Read here 
- Trigger the cloud code function in your PHP code via parse PHP SDK by sending the relevant parameters to the cloud code function that you trigger 
Comments
Explore related questions
See similar questions with these tags.