我想要使用此功能:幫助新手用PHP函數
http://www.frankmacdonald.co.uk/php/post-to-wordpress-with-php.html
其用於發佈使用XMLRPC WordPress的,誰能給我的基礎知識,使用此功能,也許一個簡單的過視圖?
我想了解功能如何工作以及如何使用它們。
編輯:
以下guideance就像一個夢。
我想通過一些條目使用foreach
循環來循環,他們都發布到WP,不知道是否有人能指教?
我想要使用此功能:幫助新手用PHP函數
http://www.frankmacdonald.co.uk/php/post-to-wordpress-with-php.html
其用於發佈使用XMLRPC WordPress的,誰能給我的基礎知識,使用此功能,也許一個簡單的過視圖?
我想了解功能如何工作以及如何使用它們。
編輯:
以下guideance就像一個夢。
我想通過一些條目使用foreach
循環來循環,他們都發布到WP,不知道是否有人能指教?
這裏沒什麼可做的,它已經準備好運行了。
只需更換在第一行中給出的示例值:
$title = 'This is the post title';
$body = 'this is the post content';
$rpcurl = 'http://www.yourwordpressblog.com/xmlrpc.php';
$username = 'myusername';
$password = 'mypassword';
$category = ''; //default is 1, enter a number here.
$keywords = 'one,two,three';//keywords comma seperated.
$encoding ='UTF-8';//utf8 recommended
一些實際數據。 (如果您的博客駐留在根目錄中,則指向xmlrpc.com的鏈接應該爲www.yourdomain.com/xmlrpc.php
)。
將整個事情放到PHP文件中,然後運行它。如果幸運的話,一切都會順利運行。如果沒有,請回來編輯您的問題。
如果你想要發佈的幾個項目,有對每一個崗位僅改變幾件事情:
RPC URL,用戶名,密碼和編碼是標準的,因爲我也假設你將它發佈到同一個網站上。所以我們只需要將4個命名項存儲在一個我們可以運行的數組中。我將這些項存儲在另一個數組中,所以我們有一個數組數組。
你可以很容易地編寫這樣的事:
// We create a post array that contains an array per post.
// I put in the data index based. First item is title, second is content body, third is category, fourth is keywords.
$posts = array(
array('Title','Contents','category','keywords'),
array('Another post','More content','another category ID','etc.'),
// You can add more items if you want.
);
// These are just general settings that are the same for each post.
$rpcurl = 'http://www.yourwordpressblog.com/xmlrpc.php';
$username = 'myusername';
$password = 'mypassword';
$encoding ='UTF-8';
foreach($posts AS $Post)
{
// From the foreach we get an array with post data each cycle.
// To keep things a bit clear, I will extract the data to seperate variables..
$title = $Post[0];
$body = $Post[1];
$category = $Post[2];
$keywords = $Post[3];
wpPostXMLRPC($title,$body,$rpcurl,$username, $password,$category,$keywords,$encoding);
}
漢斯,這真的是你的第一個貢獻?做得好! – Jack 2010-04-11 11:18:43
是的,在這個網站肯定。我在其他(荷蘭語)論壇上也待了很長時間。 – Hans 2010-04-11 11:51:24