$curl = curl_init();
$payload = Array(
'packageName' => "com.test.yourpackage", //Required Parameter
'type' => "Simple", //Optional Parameter (Default: Simple, Possible Values: Simple, Image)
'title' => "Test Title", //Required Parameter
'description' => "Test Descriptioon", //Optional
'image' => "http://test.test/image.png", //Optional (Works only when type=Image)
'url' => "http://test.com", //Optional (Must be a URL if given)
'ring' => "RING", //Optional (Default: RING, Possible Values: RING, VIBE, RINGVIBE, SILENT)
// Further parameters described below for different APIs
//Above Options are common for all requests.
);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://apis.websitetoapk.com/pushadmin/api/v1/...", // As per your request
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => http_build_query($payload),
CURLOPT_HTTPHEADER => array(
"content-type: application/x-www-form-urlencoded",
"X-Api-Key: api-key-here",
"X-Auth-Token: token-here"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Comments