使用PHP Laravel 5。似乎找不到如何做这件特定的事情。我有一个python脚本中的数据。运行python命令将成功发布到我的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中调用该字典"数据",以便在初始if语句中使用它?
谢谢!
您的意思是读取$_POST
参数吗?
if ($api_key == $_POST['api_key'] and $api_secret == $_POST['api_secret']) {