我正在尝试按小时计划一个事件,它应该将一些数据存储到mlab数据库(mongo db),但该函数不会被调用。
class plug_Activator{
public function __construct() {
add_action( 'my_hourly_event', 'tmpp' );
}
function activate() {
if ( ! wp_next_scheduled( 'tmpp' ) ) {
wp_schedule_event( time() - 3540, 'hourly', 'my_hourly_event');
}
}
function tmpp(){
$args= array(
"website"=> "www.xyz.com",
"post"=> "wasupp"
);
$response = wp_remote_post( 'https://api.mlab.com/api/1/databases/todo/collections/todos?apiKey=xxxx', array(
'headers' => array('Content-Type' => 'application/json; charset=utf-8'),
'body' => json_encode($args),
'method' => 'POST'
));
}}