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.

Category: 5hopping, PHP, Scraping
Tagged:

8 Responses

  1. +shage2:5 — #22 says:

    top notch! Thank you

  2. +Tankado1:1 — #144 says:

    Interesting code. It has blackhat seo capability. Enjoy. ;)

  3. +karum1:1 — #150 says:

    What about the tags? Is there a way to send tags as a parameter to xmlrpc?

  4. +biobrain1:1 — #154 says:

    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.

Leave a Reply

Comment Links are DoFollow only for registered subscribers … if comments pass moderation. Links in your comments may be slaughtered, hijacked or removed.