将数据从 Python POST 请求传递到 PHP

Passing data from Python POST request to PHP

使用 PHP Laravel 5。似乎无法找出如何做这个具体的事情。我在 python 脚本中有数据。 运行 python 命令将 post 成功地发送到我的 PHP 方法,并在我硬编码 api 密钥和密码时执行以下命令。

    $api_key = 1;
    $api_secret = 'sesame';

    //if api id and secret match, get oldest job with available timestamp before current time with status of 0

    if ($api_key == 1 and $api_secret == 'sesame') {

        $current_dt = '';
        $current_dt = date('Y.m.d H:i:s');

        $first_job_that_qualifies = \App\Job::orderBy('created_at', 'desc')
            ->where('status', 0)
            ->where('available_ts', '<', $current_dt)
            ->first();

        if ($first_job_that_qualifies != null){

            $first_job_that_qualifies->status = 1;
            $first_job_that_qualifies->save();
        }


    }


    }

现在我想去掉硬编码值并用我从 python 传递的数据检查它们。

    data = {
        'api_key': api_key,
        'api_secret': api_secret,
        }

    print data

    r = requests.post(quasar_url, data=data)
    print r.text

我如何在我的 PHP 函数中从 python 调用那个字典 "data" 以便我可以在我的初始 if 语句中使用它?

谢谢!

您的意思是读取 $_POST 参数吗?

if ($api_key == $_POST['api_key'] and $api_secret == $_POST['api_secret']) {