duanjie2940 2015-03-07 08:35
浏览 40

卷曲不在wordpress计划事件/ cron中工作

I created a wordpress schedule event using the following code

add_filter('cron_schedules','cliv_cron_add_syncdays');
function cliv_cron_add_syncdays($schedules){
   $schedules['syncdays'] = array(
       'interval' => 15,
       'display'=> 'Sync Days'
   );
   return $schedules;
}

add_action('init','cliv_create_recurring_schedule');
add_action('cron_action','cron_function');

function cron_function(){

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER,array("DATA SYNC"));
    $result = curl_exec($ch);
    curl_close($ch);
    $response = json_decode($result, true);

    mail("mymail@mail.com", "wp Cron test", $response);

}

function cliv_create_recurring_schedule(){
  if(!wp_next_scheduled('cron_action'))
   wp_schedule_event (time(), 'syncdays', 'cron_action');
}

if i call the cron_function() directly, everything works. But if the function is run from cron, mail is received but without the data. ( i guess curl not working in this case).

Guys. can you help me out here please.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了