[VB.NET] Lập trình đăng tin tự động lên Wordpress sử dụng XML-RPC
Đầu tiên, mình xin nói về thằng XML-RPC là gì?XML-RPC là một cài đặt RPC (Remote Procedure Call) trên nền giao thức HTTP, sử dụng XML để mã hoá và trao đổi dữ liệu.
Giao diện demo của ứng dụng auto post tin lên blog Wordpress:
Bước 1: Các bạn tạo các control và cài đặt thuộc tính cho nó như sau
Textbox 1 : Name : txtTitle
Textbox 2 : Name : txtpost, Multiline : True
Button : Name: btnPost
Bước 2: Tiếp tục chèn thư viện XMLRPC.NET vào solution, các bạn có thể download thư viện về trên trang http://xml-rpc.net.
Bước 3: Chúng ta code cho sự kiện khi click vào button btnPost như sau
Chúc các bạn thành công với thủ thuật trên.
+ Code ứng dụng bằng ngôn ngữ lập trình VB.NET
Imports CookComputing.XmlRpc Public Structure blogInfo Public title As String Public description As String End Structure Public Interface IgetCatList _ Function NewPage(ByVal blogId As Integer, ByVal strUserName As String, ByVal strPassword As String, ByVal content As blogInfo, ByVal publish As Integer) As String End Interface Dim newBlogPost As blogInfo = Nothing newBlogPost.title = txtTitle.Text newBlogPost.description = txtPost.Text categories = CType(XmlRpcProxyGen.Create(GetType(IgetCatList)), IgetCatList) clientProtocol = CType(categories, XmlRpcClientProtocol) clientProtocol.Url = "http://127.0.0.1/wpl/xmlrpc.php" Dim result As String = Nothing result = "" Try result = categories.NewPage(1, "shoban", "shoban", newBlogPost, 1) MessageBox.Show("Posted to Blog successfullly! Post ID : " & result) txtPost.Text = "" txtTitle.Text = "" Catch ex As Exception MessageBox.Show(ex.Message) End Try + Sử dụng code bằng ngôn ngữ C# using CookComputing.XmlRpc; public struct blogInfo { public string title; public string description; } public interface IgetCatList { [CookComputing.XmlRpc.XmlRpcMethod("metaWeblog.newPost")] string NewPage(int blogId, string strUserName, string strPassword, blogInfo content, int publish); } blogInfo newBlogPost = default(blogInfo); newBlogPost.title = txtTitle.Text; newBlogPost.description = txtPost.Text; categories = (IgetCatList)XmlRpcProxyGen.Create(typeof(IgetCatList)); clientProtocol = (XmlRpcClientProtocol)categories; clientProtocol.Url = "http://127.0.0.1/wpl/xmlrpc.php"; string result = null; result = ""; try { result = categories.NewPage(1, "shoban", "shoban", newBlogPost, 1); MessageBox.Show("Posted to Blog successfullly! Post ID : " + result); txtPost.Text = ""; txtTitle.Text = ""; } catch (Exception ex) { MessageBox.Show(ex.Message); }
Chúc các bạn thành công với thủ thuật trên.
Theo LapTrinhVB.Net
4 comments:
HIỆN TẠI CHƯƠNG TRÌNH NÀY KHÔNG HOẠT ĐỘNG ĐC NỮA NHÉ MỌI NGƯỜI VÌ K THỂ DOWNLOAD FILE TỪ XML-PRC NỮA. TKS
thanks for share, please help me code auto post any more website for web? tks adm
what is this website?
trang tải file .dll bị die rồi kìa adm? k có dữ .dll để gọi dữ liệu thì có cách nào khác k?
Post a Comment