简体   繁体   English

无法获取数据是从android发布到Yii2动作

[英]cant get data was Post from android to Yii2 action

I have a problem when I post data from android to Yii2 action, I have actionAdd in controller Like this 我将数据从android发布到Yii2 action时遇到问题,我在controller中有actionAdd,就像这样

    public function actionAdd()
{
    $model = new Orders();

    if( isset($_POST['orders_id']) && isset($_POST['orders_uid']) && isset($_POST['orders_bid']) && 
        isset($_POST['orders_sid']) && isset($_POST['orders_quantity']) && isset($_POST['orders_cost']) && 
        isset($_POST['orders_discount']) && isset($_POST['orders_date']) && isset($_POST['orders_sync_status'])){
        $model->orders_id           = $_POST['orders_id'];
        $model->orders_uid          = $_POST['orders_uid'];
        $model->orders_bid          = $_POST['orders_bid'];
        $model->orders_sid          = $_POST['orders_sid'];
        $model->orders_quantity     = $_POST['orders_quantity'];
        $model->orders_cost         = $_POST['orders_cost'];
        $model->orders_discount     = $_POST['orders_discount'];
        $model->orders_date         = $_POST['orders_date'];
        $model->orders_sync_status  = $_POST['orders_sync_status'];

        $model->save(false);
    }
}

And in my android app I set this URL 然后在我的android应用中设置此URL

HttpPost httppost = new HttpPost("http://192.168.101.147/yii/mobile_orders/backend/web/orders/add");

when I post I think its not go to action, Since I try to create simple php page on the server and Im get a POST data Truth, Also Im try to set actionAdd code in index.php under web yii2 root, and its work fine .. but when I try use action page, Im not get any data .. any help ^_^ 当我发布文章时,我认为它不起作用,因为我尝试在服务器上创建简单的php页面,并且我得到了POST数据真相,我也尝试在web yii2根目录下的index.php中设置actionAdd代码,因此它的工作正常..但是当我尝试使用操作页面时,我没有得到任何数据..任何帮助^ _ ^

thanks 谢谢

您可以在运行的应用程序下设置操作代码,这将起作用(例如index.php获取代码并对其进行设置,它将起作用..但是我确定这不是一个好的解决方案)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM