Last active
March 25, 2016 18:51
-
-
Save woodwardtw/888784031adfd1874bf6 to your computer and use it in GitHub Desktop.
makes a weekly blog post from the contents of the curl'd page - triggered weekly by cron task
This file contains 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 | |
define('WP_USE_THEMES', false); | |
require('./wp-blog-header.php'); | |
?> | |
<?php | |
function make_post (){ | |
$curl = curl_init(); | |
curl_setopt ($curl, CURLOPT_URL, "http://bionicteaching.com/tools/pinboard/index.php"); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
$result = curl_exec ($curl); | |
curl_close ($curl); | |
$date = date_create('now'); | |
$lastweek = date_sub($date, date_interval_create_from_date_string('7 days')); | |
$lastweek = date_format($date, 'Y-m-d'); | |
$my_post = array( | |
'post_title' => 'Weekly Web Harvest for ' . $lastweek , | |
'post_content' => $result, | |
'post_status' => 'draft', | |
'post_author' => 1, | |
'post_category' => array( 601 ) | |
); | |
// Insert the post into the database | |
wp_insert_post( $my_post ); | |
} | |
?> | |
<?php | |
make_post(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment