1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Externally Post Content To Your WordPress Sites

Discussion in 'Blogging' started by blackhatcodex, Sep 14, 2011.

  1. blackhatcodex

    blackhatcodex BANNED BANNED

    Joined:
    Aug 28, 2011
    Messages:
    144
    Likes Received:
    248
    Here's a little script to post blog content to your WordPress sites. It may be useful when you don't want to go into the dashboard each time to post a new article or want to post to a multitude of WordPress sites at the same time.

    PHP:
    <?php 
    require_once("IXR_Library.php.inc");
     
    $client->debug true//Set it to false in Production Environment
     
    $title="Blog Title"// $title variable will insert your blog title 
    $body="Blog Content"// $body will insert your blog content (article content)
     
    $category="category1, category2"// Comma seperated pre existing categories. Ensure that these categories exists in your blog.
    $keywords="keyword1, keyword2, keyword3";
     
    $customfields=array('key'=>'Author-bio''value'=>'Autor Bio Here'); // Insert your custom values like this in Key, Value format
     
     
        
    $title htmlentities($title,ENT_NOQUOTES,$encoding);
        
    $keywords htmlentities($keywords,ENT_NOQUOTES,$encoding);
     
        
    $content = array(
            
    'title'=>$title,
            
    'description'=>$body,
            
    'mt_allow_comments'=>0,  // 1 to allow comments
            
    'mt_allow_pings'=>0,  // 1 to allow trackbacks
            
    'post_type'=>'post',
            
    'mt_keywords'=>$keywords,
            
    'categories'=>array($category),
            
    'custom_fields' =>  array($customfields)
     
     
        );
     
    // Create the client object
    $client = new IXR_Client('Your Blog Path/xmlrpc.php');
     
     
    $username "USERNAME"
     
    $password "PASSWORD"
     
    $params = array(0,$username,$password,$content,true); // Last parameter is 'true' which means post immideately, to save as draft set it as 'false'
     
    // Run a query for PHP
    if (!$client->query('metaWeblog.newPost'$params)) {
        die(
    'Something went wrong - '.$client->getErrorCode().' : '.$client->getErrorMessage());
    }
    else
        echo 
    "Article Posted Successfully";
     
    ?>
    ******** I can't post the virus scan due to forum moderation, but it's just a .txt file for the IXR_Library.php.inc **********
     

    Attached Files:

    • Thanks Thanks x 1
    Last edited: Sep 14, 2011
  2. SyZygy

    SyZygy Senior Member

    Joined:
    Dec 29, 2009
    Messages:
    864
    Likes Received:
    1,080
    Location:
    Europe
    Home Page:
    Is this your script?
    If yes, can you add some details to it?
    If also yes, PM me
     
  3. blackhatcodex

    blackhatcodex BANNED BANNED

    Joined:
    Aug 28, 2011
    Messages:
    144
    Likes Received:
    248
    Sure :)

    Chance IXR_Library.txt (located in the zip file) to IXR_Library.php.inc

    Just edit the blog title, blog content, category, and keywords areas. Then where is says "USERNAME"/PASSWORD", place in your username and password for your website.

    Where it says: $client = new IXR_Client('Your Blog Path/xmlrpc.php');

    change it to:

    $client = new IXR_Client('YOUR-WORDPRESS-SITE/xmlrpc.php');
     
  4. wickedguy

    wickedguy Supreme Member

    Joined:
    Jul 22, 2009
    Messages:
    1,402
    Likes Received:
    1,379
    Location:
    BHW--> South Africa
    Home Page:
    You forgot to mention that XMLRPC must be enabled for it to work :D
     
  5. edgematch

    edgematch Elite Member

    Joined:
    May 24, 2010
    Messages:
    2,538
    Likes Received:
    1,949
    Occupation:
    You can never guess!
    Location:
    :noitacoL
    thanked and +4 repped...

    waiting to chat on skype...
     
  6. shankshera

    shankshera Junior Member

    Joined:
    May 18, 2010
    Messages:
    193
    Likes Received:
    25
    How to use it? Sorry, I'm so newbie here.