Trying to do this in php
curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" -u xxx:xxx -d '{ "broadcast": true, "title": "Hello World", "message": "from Kumulos Push" }' "https://push.kumulos.com/notifications" In php I have this...
$ch = curl_init( 'https://push.kumulos.com/notifications' ); curl_setopt_array( $ch, [ CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_HEADER => [ 'Content-Type: application/json', 'Accept: application/json', 'Content-Length: ' . strlen( $data ), ], CURLOPT_USERPWD => 'xxx:xxx', CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => $data, ] ); $resp = htmlentities( curl_exec( $ch ) ); Still in php I get redirected whereas in command line I get the expected response...
UPDATE
It returns this HTML in PHP, whereas in command line I get expected JSON
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta http-equiv="refresh" content="1;url=https://push.kumulos.com" /> <title>Redirecting to https://push.kumulos.com</title> </head> <body> Redirecting to <a href="https://push.kumulos.com">https://push.kumulos.com</a>. </body> </html> Update : data sent with php request
$data = json_encode( [ "title" => "Hello World", "message" => $message, "installIds" => [ $deviceToken, ], ] ); Update : Expected output ( received in command line curl )
{ "appId":9999, "source":2, "status":1, "filters":{ "installIds":[ "xxx" ] }, "title":"Test", "message":"3 new questions on Tomorrow Times!", "data":null, "isBackgroundData":false, "url":null, "targetedRecipients":0, "expectedResolutionSteps":0, "completedResolutionSteps":0, "expectedBatches":0, "completedBatches":0, "updatedAt":"2017-06-16T04:58:54+0000", "createdAt":"2017-06-16T04:58:54+0000", "id":13976 }