我正在使用curl来访问 php 来执行POST方法。问题是使用该POST方法,if它不起作用,我得到参数丢失的错误。php代码:
if(isTheseParametersAvailable(array('title','email', 'message'))){
if(isset($_POST['title']) and isset($_POST['message'])){
//creating a new push
//if the push don't have an image give null in place of image
$push = new Push(
$_POST['title'],
$_POST['message'],
null
);
//getting the push from push object
$mPushNotification = $push->getPush();
//getting the token from database object
echo $devicetoken = $db->getTokenByEmail('irina@yahoo.com');
//creating firebase class object
$firebase = new Firebase();
//sending push notification and displaying result
echo $firebase->send($devicetoken, $mPushNotification);
}else{
$response['error']=true;
$response['message']='Parameters missing';
}
邮递员截图:
isThereParametersAvailable功能:
function isTheseParametersAvailable($params){
foreach($params as $param){
if(!isset($_POST[$param])){
return false;
}
}
return true;
}
摇曳的蔷薇