Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
makes a weekly blog post from the contents of the curl'd page - triggered weekly by cron task
<?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
You can’t perform that action at this time.