Created
September 7, 2022 11:11
-
-
Save autocircled/b46f41df79910351a98ea1b64f5efe91 to your computer and use it in GitHub Desktop.
Recursively remote call using wp_remote_post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Increase day by 1 to call the API for next day | |
$current_date = date( 'Y-m-d', strtotime( $current_date . '+1 day' )); | |
// Checking if everything is working fine | |
$file = plugin_dir_path( __FILE__ ) . '/text.txt'; // This line is not tested yet! So careful before use | |
file_put_contents( $file, $this->fetched_day_counter . ': Current Date: ' . $current_date . "\n\n", FILE_APPEND ); | |
// Ready for the next day | |
$this->fetched_day_counter += 1; | |
update_option( 'fetched_day_counter', $this->fetched_day_counter ); | |
// Go and call for next day fixtures | |
wp_remote_post( admin_url( 'admin-ajax.php?action=get_matches_from_api' ), [ | |
// Below line is added so that all the process works smoothly, its not delay to loading wordpress | |
'blocking' => false, | |
// Below line is added for localhost environment. Otherwise ssl related error may appear. | |
'sslverify' => false, | |
'body' => [ | |
'date' => $current_date, | |
] | |
] ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment