Receiving HTTP data in Yii2 action from an Unknown URL

早过忘川 提交于 2019-12-11 17:14:47

问题


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.

来源:https://stackoverflow.com/questions/52477451/receiving-http-data-in-yii2-action-from-an-unknown-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!