PHP的 - 如何通过在Curl的cron选项卡执行ajax方法?
我想知道如何让我的ajax请求在crontab中运行? 我在这里有一个ajax请求,从api获取数据,对于每个数据我正在执行ajax post请求来更新我的数据库中的一行。
我该如何在Curl中做到这一点?
这里是我的脚本,
function getDataFs()
{
var _token = $("input[name='_token']").val();
$.ajax({
url: 'https://url/api/employees',
type: 'GET',
dataType: 'json',
xhrFields: {
withCredentials: true
},
success: function(response){
console.log(response);
for(i=0; i < response.length; i++)
{
$.ajax({
url: '/api/update_employees_list',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
type: 'POST',
dataType: 'json',
data: { 'employee_data': response[i], '_token': _token },
success: function(response){
console.log(response);
}
})
}
}
});
}
我也通过请求头和XHR领域,
我希望有人能帮助我,如果没有可能在阿贾克斯,你能帮帮我在Curl或任何可能的解决方案上完成此操作, 谢谢!