Receiving HTTP data in Yii2 action from an Unknown

2019-08-18 19:17发布

问题:

I have been trying to receive data send to my Yii2 action for a while now but to no success. I have tried lots of different algorithms and ideas. I am working on receiving data sent to me by Orange API for base on clients payment status. from Instructions on their website, they say, once the status has been confirmed, ..... HTTP notification is posted to the notif_url( my notification URL which I provided to them say https://www.example2.org/notif ). They futher provide the format for the data as:

POST http://www.example2.org/notif
{ "status":"SUCCESS", "notif_token":"dd497bda3b250e536186fc0663f32f40", "txnid": "MP150709.1341.A00073" }

I have written my Yii2 Action as shown below

public function actionNotif(){
    $request = Yii::$app->request->post();
    $transaction = OrangeFeedback::findOne(['notif_token'=>$request->notif_token]);
    $transaction->status = $request->status;
    $transaction->txnid =  $request->txnid;
    $transaction->save();
    if($request->status == 'SUCCESS'){
        //Do some processing

But this code doesn't work. I do not understand what I am missing in receiving this request. Please any help will be greatly appreciated.

标签: php yii2