Sticky Posts
Jul 22, 2009
Scraped Content + elWpAPI = Autoblog v/Light
A customer asked for a fully fledged sample on how to use elWpAPI and I came up with this example. It uses my RSS parser to show you how to start up your own autoblogs. Takes content from a chosen feed and publishes posts with the contents. It's basic but you can build on it.
<?php
// ------------------------------------------- //
// Setup your XMLRPC accessible blog details
$blog_address = 'http://www.blog.wp/';
$blog_username = 'admin';
$blog_password = 'parola';
// Assuming it's in same folder
$wpapiphp_path = dirname(__FILE__);
// Change this to a real feed
$feed_to_scrape = 'http://www.blog.wp/feed/';
// First include the wpapi.php wherever you have it located
require_once($wpapiphp_path.'/wpapi.php');
// ------------------------------------------- //
// Create the new elWpAPI object
$wp = new elWpAPI(
rtrim($blog_address, '/').'/xmlrpc.php', // Blog URL
$blog_username, $blog_password // Blog Credentials
);
// *** From here on you can paste any sample from the WPAPI source page *** //
// Create A New Category
$catID = $wp->newCategory('Scraped');
// Load RSS feed entries
$rss = el_xml_loadRSS($feed_to_scrape);
// IDs of new posts
$posts = array();
// Loop through RSS entries
foreach($rss as $post){
// Text can be content or description
$text = isset($post->content) ? $post->content : $post->description;
// Create A Post ... the 'light' way
$posts[$post->title] = $wp->newPost(
$post->title, // New Post Title
$text, // New Post Text
array($catID), // New Post Categories
true // Publish directly
);
}
// Show posts
print_r($posts);
// ------------------------------------------- //
?>
To All Customers: Download the new elWpAPI Version but keep the old one too :) See the change log.


top notch! Thank you
Interesting code. It has blackhat seo capability. Enjoy. ;)
What about the tags? Is there a way to send tags as a parameter to xmlrpc?
$post = new elWpNewPost();
$post->add_keywords(’tag1′, ‘tag2′);
and use newPostEx in elWpAPI.
I am looking for a similar script but i do not want to get data from rss but want to put the post data manually.
please tell me how i can use the above script.
The elWpAPI does it but it’s not free. See the examples on this page.
The link doesn’t work..
Thanks for the warning. Fixed it.