我尝试运行一个cronjonb来调用几个网址,每次打开页面时都会提交(或更新)Wordpress帖子。
$sy_json_match_cal=file_get_contents('url');
$sy_match_cal = json_decode($sy_json_match_cal,true);
$sy_match_calendar = $sy_match_cal['data'];
foreach ($sy_match_calendar as $sy_objects) {
$runscript = file_get_contents('https://www.url.com/single/?match_id=754733&hteam=7020&ateam=3343&season=313&competition=261');
}
我猜一切都按编码工作,但没有提交的帖子。也许file_get_contents('urls');
不是正确的方法吗?
这是目标网址中的提交帖子部分:
// create new match post
$title = $rf_match_id;
$post = get_page_by_title( $title, 'OBJECT', 'matches' );
if(NULL===$post){
// insert post
$new_match = array();
$new_match['post_title'] = $title;
$new_match['post_content'] = '';
$new_match['post_type'] = 'matches';
$new_match['post_status'] = 'publish';
$new_match['post_author'] = 1;
$new_match['post_category'] = array(0);
$id = wp_insert_post ( $new_match );
update_post_meta($id,'date',$scr_facts_date);
update_post_meta($id,'kick_off',$scr_facts_ko_utc);
update_post_meta($id,'match_id',$rf_match_id);
wp_update_post( $update_match );
}else{
// update match post
$id = $post->ID;
$update_match = array();
update_post_meta($id,'date',$scr_facts_date);
update_post_meta($id,'kick_off',$scr_facts_ko_utc);
update_post_meta($id,'match_id',$rf_match_id);
wp_update_post( $update_match );
}
当我手动打开这些“网址”时,会提交或更新帖子。知道为什么那可能不会这样吗?
参数是否有问题?
非常感谢!