MetaWebLog API - the idea of a multi-platform synchronization article

The article is from my blog: https://blog.ljyngup.com/archives/578.html/

Due

In order to bring traffic to the blog, I opened an account on CSDN, garden blog, Jane books and some of the blog can publish these articles are platform release.

But at the same time maintains three blog platform is too much trouble, if there is a place you want to modify, all three blog platform you want to modify. So now basically not simultaneously released, but I still want to achieve blog platform synchronization publication, modification .

Park began research blog article published interfaces, beginning capture their own analysis and found it troublesome. So Google, the Metaweblog found this very easy to use API

Introduction

XML-RPC is a remote procedure call (Remote Procedure Call) (remote procedure call, RPC) protocol distributed computing, the XML by calling the function packages and using the HTTP protocol as the transmission mechanism.

XML-RPC was published in 1998, jointly published by UserLand Software (UserLand Software) of Dave Winer and Microsoft. Later, under the new features are constantly being introduced, this gradually evolved into today's standard SOAP protocol.

This shows that the agreement released very early, its official website to stay in 2004. Information on this area is very small, only to find a little hint in the MSDN blog and garden early in the article.

But we are talking about Metaweblog, why introduce XMLPRC?

MetaWeblog API (MWA) is a programming interface that allows external programs to get and set the text and attributes weblog posts. It builds on the popular XML-RPC protocol, can be used to achieve many popular programming environments.

In 2003 on the occasion, many blog platforms began to support MetaWeblog API, allowing third-party content manager and editor of the blog editing management.

Now, for example MWeb, Windows Live Writerthe articles published are based on this API-based!

And this API, synchronization is the key blog where 9102 years!

Interface Description

Toss two days, the blog is a garden with a small error in the article and made the whole mentality of collapse, then check MSDN only be successful request.

To blog Park, for example, these interfaces

blogger.deletePost - delete articles
blogger.getUsersBlogs - get user information blog
metaWeblog.editPost - edit the article
metaWeblog.getCategories - get user blog classification
metaWeblog.getPost - for articles
metaWeblog.getRecentPosts - Get recent article
metaWeblog. newMediaObject - add media objects (images, etc.)
metaWeblog.newPost - add articles
wp.newCategory - Add directory

Our main interface is used getUsersBlogs; editPost; getRecentPosts; newPost.

Publish articles by newPost cycle multi-platform, editPost and getRecentPosts as a method of follow-up management and editing.

The getUsersBlogs may or may not, want to get blogid by this method on some platforms can implement the following methods, but as long as the account password garden blog can be achieved.

However, this method can obtain the user name, user experience tools helpful

Implementation process

Debugging tools: Yi Jing page Assistant
API interface address: https://rpc.cnblogs.com/metaweblog/ blog name
the access method: POST
Code:UTF-8

1.blogger.getUsersBlogs

Parameters:
. 1) [String] xmlrpc_url (i.e. API interface address above)
2) [String] username (Park blog account)
. 3) [String] pwd (blog Park password)

This step bloggers to get information above actually comes to this step can be omitted, but in order to write the following tools, we still demonstrate.
file
This shows that we successfully obtained blogid and user name (non-blog name)

2.metaWeblog.newPost

Parameters:
. 1) [String] the blogid (tested, but this can not be ignored by deleting the corresponding label)
2) [String] username
. 3) [String] pwd
. 4) [struct] Post (this is a structure, with particular reference to Park blog document at the end of the text)
5) [BOOL] publish (whether to publish .1 to publish, not to publish 0)

Here two Tucao an article, blog Park gave an example of this approach, but I always request show Request from client does not contain valid XML.but I submit no XML error until you find an example on MSDN, and when he saw encoding.
Yes, post information submitted must be in UTF-8 encoding , gb2312 been submitted before, always an error. Of course, if you do not submit the Chinese, encoded random ~

Demo:
file

String instructions that appear successful release, the string for the article postid

Blog page:
file

Release success, the last is just to get the postid URL address of the contents is also just submitted.

The most important step is the longest step of the pit I get ~

3.metaWeblog.getRecentPosts

Parameters:
. 1) [String] the blogid (ignored)
2) [String] username
. 3) [String] pwd
. 4) [int] numberOfPosts (acquired number of articles)

This is the next thing I want to do a functional tool for viewing is synchronized to the latest articles

Demo (parse tree is very long, cut is not complete, right):
file

4.metaWeblog.editPost

Use the same newPost postid is just to add a parameter that can be acquired in getRecentPost ~

A little summary

This is a very useful interface, known domestic CTO, blog garden, open-source Chinese support this method of publishing the article. Then you can write a blog published sync tool, as an independent blog entry traffic, improve the synchronization efficiency!

Reference article

The reference article feeling is 2000 times, own a little bit of research to check documents is not easy ......

Guess you like

Origin www.cnblogs.com/ljysblog/p/12336878.html