Is there a WP Post dripper?

Pb.com

New member
Mar 22, 2011
658
3
0
Is there a WP post dripper that basically takes drafts and allows me to set them to drip over a set period of time or post them at random intervals over X amount of days?

If not... it would be useful.
 


Thanks kpaul. That might be the way to go. I could just use csv importer but that brings a major pain.

Cash, nice recommendation. I think I tried that one and it was broken but I coil be mistaken. I haven't had this problem in 4 or 5 months but what lies ahead of me is a much bigger pain in the ass then coding a solution.
 
Got one working. It takes the # of drafts divides number of "X" days and posts at that interval+ or - random number between 0-60 minutes. Also put in a feature to reset all posts to drafts.
 
index.php
PHP:
<?php
require 'functions.php';
$url = 'www.test.com';
$username = 'admin';
$password = 'test';
$title = 'test1';
$post = 'This is an automated test post';
$timestamp = '1306342800';
$categories = 'test';

$file = 'posts.txt';
$f = fopen($file, "r");
while(!feof($f)){
  $data[] = fgets($f);
}
fclose($f);

$i=0;
foreach($data as $post){
  $i++;
  $title = 'Title #'.$i;
  $ret = postwp($url,$username,$password,$title,$post,$timestamp,$categories);
  echo $ret.'<br/>';
  set_time_limit(180);
  $timestamp = strtotime('+ 3 days', $timestamp);
  $date = date(c, $timestamp);
}
echo '-------------------------------------<br>'.$i.' posts scheduled';
?>
functions.php
PHP:
<?php 
function scheduler($timestamp, $days){
  strtotime('+'.$days.' day', $timestamp);
  $date = date(c, $date);
  return $date;
}

function postwp($url,$username,$password,$title,$post,$date,$categories){

  $request = createxml($username,$password,$title,$post,$date,$categories);
  $xmlresponse = get_response($url."/xmlrpc.php", $request);
  
  return $xmlresponse;
}

function get_response($URL, $context) {
    if(!function_exists('curl_init')) {
        die ("Curl PHP package not installed\n");
    }

    /*Initializing CURL*/
    $curlHandle = curl_init();

    /*The URL to be downloaded is set*/
    curl_setopt($curlHandle, CURLOPT_URL, $URL);
    curl_setopt($curlHandle, CURLOPT_HEADER, false);
    curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
    curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $context);

    /*Now execute the CURL, download the URL specified*/
    $response = curl_exec($curlHandle);
    return $response;
}

function createxml($username,$password,$title,$description,$date,$categories){

$request = '<?xml version="1.0" encoding="iso-8859-1"?>
<methodCall>
<methodName>metaWeblog.newPost</methodName>
<params>
 <param>
  <value>
   <int>1</int>
  </value>
 </param>
 <param>

  <value>
   <string>'.$username.'</string>
  </value>
 </param>
 <param>
  <value>
   <string>'.$password.'</string>
  </value>

 </param>
 <param>
  <value>
   <struct>
    <member>
     <name>title</name>
     <value>
      <string>'.$title.'</string>

     </value>
    </member>
    <member>
     <name>description</name>
     <value>
      <string>'.$description.'</string>
     </value>
    </member>

    <member>
     <name>date_created_gmt</name>
     <value>
      <strong><dateTime.iso8601>'.$date.'</dateTime.iso8601></strong>
     </value>
    </member>
    <member>
     <name>categories</name>

     <value>
      <array>
       <data>
        <value>
         <string>'.$categories.'</string>
        </value>
        <value>
         <string>History</string>

        </value>
       </data>
      </array>
     </value>
    </member>
   </struct>
  </value>
 </param>
 <param>

  <value>
   <boolean>1</boolean>
  </value>
 </param>
</params>
</methodCall>
';
return $request;
}
?>
Adjust to suit your needs, this one has a set title that just changes numbers.