如何以编程方式将博客发布到wordpress

问题描述:

我正在寻找API,我可以使用它以编程方式发布WordPress上的博客。 请注意,我想将用户重定向到wordpress,因此我正在寻找一个“GET”wordpress API。如何以编程方式将博客发布到wordpress

+0

你是说HTTP职位是不是可行?如果你确实重定向到WordPress,那么正常的重定向如何不能满足这种需求?我对你想要的东西有点困惑。 – 2011-02-02 12:48:19

Wordpress支持Atom发布协议和XML-RPC。简化解决方案可能是使用邮件后功能。您的程序可通过电子邮件发送博客条目。

+0

你能指点我一些使用Atom发布协议和XML-RPC的例子以及如何在代码中使用它吗? – TopCoder 2011-02-02 12:20:11

+0

我还没有必要这样做,但这里有一个很好的起点(由Eric Kidd编写):http://tldp.org/HOWTO/XML-RPC-HOWTO/index.html – 2011-02-02 12:41:23

+0

也请看博客这里的API:http://www.xmlrpc.com/ – 2011-02-02 12:44:02

看看WordPress XML-RPC Support,它向您展示了如何在客户端中使用不同的API,例如Blogger API,metaWeblog API和Movable Type API。

可以使用WordPress的功能wp_insert_post

// Create post object 
    $my_post = array(
    'post_title' => 'My post', 
    'post_content' => 'This is my post.', 
    'post_status' => 'publish', 
    'post_author' => 1, 
    'post_category' => array(8,39) 
); 

// Insert the post into the database 
    wp_insert_post($my_post);