上周做了一個銀魂的網站
http://www.iyinhun.com
喜歡吐槽的熱血動畫的粉絲可以看看。
因為一個人做,比較吃力,我就想做一個自動維護程序(其實就是采集器的意思)
下面公布一下php向這類網站發送文章的代碼(php向wordpress,blogbus,cnblogs等支持xmlrpc的網站離線發帖的代碼)
分類屬性(categories,mt_keywords)自己改。
附件裡是wordpress xmlrpc協議的類庫
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;
}