Blog article choose self: blog.ljyngup.com/archives/57…
The cause of
In order to drive traffic to my blog, I set up accounts on CSDN, Blog Garden, and Jane Book and also published some of the publishable articles from my blog on these platforms.
But maintaining all three blogging platforms at the same time is too cumbersome, and once something needs to be changed, all three blogging platforms need to be changed. So now there is basically no synchronous release, but I always want to achieve blog platform synchronous release, synchronous modification.
So I began to study the interface of blog park to publish articles. At the beginning, I captured and analyzed the packages myself, but I found it was really troublesome. So Google discovered Metaweblog, which is a really nice API
introduce
Xml-rpc is a distributed computing protocol for remote Procedure Call (RPC), which encapsulates the calling function through XML and uses HTTP protocol as the sending mechanism.
Xml-rpc was published in 1998 by Dave Winer of UserLand Software (UserLand Software) and Microsoft. As new features were introduced, the standard evolved into today’s SOAP protocol.
As you can see, this agreement was released very early, and its official website is stuck in 2004. There is very little information on this subject, and only a hint of it can be found in MSDN and early blogosphere articles.
We’re talking about Metaweblog, so why XMLPRC?
The MetaWeblog API (MWA) is a programming interface that allows external programs to get and set the text and properties of weblog posts. It is built on the popular XML-RPC communication protocol and can be implemented in many popular programming environments.
In 2003, many blogging platforms began to support the MetaWeblog API, which allows third-party editors and content managers to edit and manage blogs.
At present, articles such as MWeb and Windows Live Writer are published based on this API!
And this API is the key to blog syncing in 9102!
The interface is introduced
Toss and turn for two days, by a blog garden with a small mistake of the article made the mentality of the whole collapse, later check MSDN can be successful request.
The blogosphere, for example, has these interfaces
Blogger. deletePost – Deletes the post
Blogger.getusersblogs – Gets user blog information
Metaweblog. editPost – Edit articles
Metaweblog.getcategories – Gets user blog categories
Metaweblog.getpost — Get the article
The metaWeblog. GetRecentPosts — — get the recent articles
The metaWeblog. NewMediaObject — — add media objects (pictures, etc.)
Metaweblog.newpost — Add articles
Wp.newcategory — Add a directory
The main interface we use is getUsersBlogs; EditPost; GetRecentPosts; newPost.
Multi-platform posts are published through the newPost loop, with editPost and getRecentPosts as subsequent management and editing methods.
GetUsersBlogs may or may not be available. On some platforms, you need to get the blogid to implement the following method, but the blog garden can be implemented as long as the account password.
However, this method can get the user name, which is helpful for the user experience of the tool
The implementation process
Debugging tools: fine easy web assistant API interface address: https://rpc.cnblogs.com/metaweblog/ blog name access methods: POST code: utf-8
1.blogger.getUsersBlogs
Xmlrpc_url parameters: 1) [string] * * * * (i.e., the API interface address) 2) [string] * * username * * garden account (blog) 3) PWD [string] * * * * (blog garden password)
This step is to get the information of the blogger, which can be omitted as mentioned above, but we will continue to demonstrate it for the following tools.We successfully obtained the blogid and username (not the blog name)
2.metaWeblog.newPost
Parameters: 2)[string]**username**3)[string]** PWD **4)[struct]**Post** 5)[bool]**publish**(1 indicates publish,0 indicates not publish)
A blog post gave an example of this method, but my Request always says Request from client does not contain valid XML. But I submitted the XML with no errors until I found an example on MSDN and suddenly saw encoding. Yes, the post submission must be encoded in UTF-8 and was always submitted as GB2312, always with an error. Of course, if you do not submit Chinese, coding arbitrary ~
Presentation:
The string displayed indicates that the publication was successful, and the string is the postid for the article
Blog page:
The post is successful, and at the end of the URL is the postid you just got and the content you just submitted.
The most important step, but also pit me the longest step to fix ~
3.metaWeblog.getRecentPosts
Parameters: 1) the blogid [string] * * * * (ignored) 2) username [string] * * * * 3) PWD [string] * * * * 4) numberOfPosts (int) * * * * (access) the number of articles
This is one of the features I want to see if I can sync up to the latest articles
Demo (long parse tree, incomplete truncation, correct) :
4.metaWeblog.editPost
The same usage as newPost simply adds a postid argument, which is available in getRecentPost
A summary
This is a very useful interface, known domestic CTO, blog garden, open source China all support this method to publish articles. Then you can write a blog syncing tool that acts as an entry point for independent blog traffic and improves syncing efficiency!
Refer to the article
The articles referred to this time are felt to be in the age of 2000, and it is not easy to check the documents a little bit.
- Xml-rpc simple understanding with blog garden’s MetaWeblog protocol
- MetaWeblog blog garden document
- MetaWeblog – Wikipedia
- XML – Wikipedia
- XMLRPC website
- Metaweblog. newPost Example -msdn