0

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?

asked May 4, 2017 at 22:01
2
  • There's an ready to use library for php - why build your own? Commented 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. Commented May 4, 2017 at 23:28

2 Answers 2

1

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.

answered Jul 3, 2017 at 18:17
Sign up to request clarification or add additional context in comments.

Comments

0

client push is not supported in parse-server (Read here) so in order to send push notifications you must do the following:

  1. 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

  2. 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

answered May 7, 2017 at 12:54

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.