我正在使用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('[email protected]'); //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; }
1 回答
搖曳的薔薇
TA貢獻1793條經驗 獲得超6個贊
您必須發送參數是正文部分才能在 $_POST 中獲取。
見下圖。

<?php
if(isset($_POST['header'])) {
echo 1;
}
- 1 回答
- 0 關注
- 242 瀏覽
添加回答
舉報
0/150
提交
取消
