Home  >  Article  >  Backend Development  >  PHP code for offline posting to WordPress and other websites that support xmlrpc_PHP tutorial

PHP code for offline posting to WordPress and other websites that support xmlrpc_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:12:40916browse

I made a Gintama website last week
http://www.iyinhun.com
Fans of hot-blooded anime who like to complain can check it out.

Because it is quite difficult to do it alone, I want to make an automatic maintenance program (actually it means collector)
Below is the code for PHP to send articles to such websites (the code for PHP to post offline to WordPress, blogbus, cnblogs and other websites that support xmlrpc)
Change the classification attributes (categories, mt_keywords) yourself.
Attached is the class library of wordpress xmlrpc protocol

function send_to_other($web,$title,$con,$USER,$PASS,$count=-1)  { 
		$client = new IXR_Client($web);
        $content['title'] = $title;
        //$get_post_info->post_category;
        $content['categories'] = array("同人");
        $content['description'] = $con;
       // $content['custom_fields'] = array( array('key' => 'my_custom_fied','value'=>'yes') );
        $content['mt_keywords'] = '同人';
    
		  if (!$client->query('metaWeblog.newPost','', $USER,$PASS, $content, true)) 
		        {
		            die( 'Error while creating a new post' . $client->getErrorCode() ." : ". $client->getErrorMessage());  
		        }
		        $ID =  $client->getResponse();
		        
		        if($ID)
		        {
		           // echo 'Post published with ID:#'.$ID;
		        }    
		   return $post_ID;  
}  

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444555.htmlTechArticleLast week I made a Gintama website http://www.iyinhun.com Fans of passionate anime who like to complain You can take a look. Because it is difficult to do it alone, I want to make an automatic maintenance program (actually...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn