2010-08-19 4 views
0

Ceci est le code que j'ai jusqu'à présent (non je n'ai pas tout écrit par moi-même a pris l'aide de net) mais je suis incapable de comprendre pourquoi je reçois cette erreuren utilisant l'application vb.net pour poster sur wordpress blog

Imports CookComputing.XmlRpc 

Public Structure blogInfo 
    Public title As String 
    Public description As String 
End Structure 


<XmlRpcUrl("http://127.0.0.1/wordpress/xmlrpc.php")> _ 
Class MsnSpacesMetaWeblog 
    Inherits XmlRpcClientProtocol 


    <XmlRpcMethod("metaWeblog.newPost")> _ 
    Function NewPage(ByVal blogID As Integer, ByVal strUserName As String, ByVal strPassword As String, ByVal content As blogInfo, ByVal publish As Integer) As String 

     Return CStr(Me.Invoke("newPost", New Object() {blogID, strUserName, strPassword, content, publish})) 
    End Function 

End Class 

Public Class Form1 

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 

     Dim mw As MsnSpacesMetaWeblog = New MsnSpacesMetaWeblog 

     Dim newBlogPost As blogInfo 
     newBlogPost.title = TextBox1.Text 
     newBlogPost.description = TextBox2.Text 

     Try 
      Dim id As String = mw.NewPage(1, "******", "******", newBlogPost, 1) 

      MsgBox("Posted to Blog successfullly! Post ID : " + id) 
      TextBox1.Text = "" 
      TextBox2.Text = "" 
     Catch ex As Exception 
      MsgBox(ex.Message) 
     End Try 
    End Sub 
End Class 
erreur

je reçois est "invoquons sur inexistant ou méthode proxy non-public"

J'apprécierais vraiment si quelqu'un peut expliquer ce que je fais mal

Thnaks

+0

Etes-vous sûr que vous ne pouvez pas écrire simplement le post dans la base de données mysql? Cela a fonctionné pour moi assez facilement. –

Répondre

0
Imports CookComputing.XmlRpcde 

Public Class frmMain 'Form name/class Form1 is the default. 
    Public Structure category 
     Public categoryId As Object 
     Public parentId As Object 
     Public description As Object 
     Public categoryName As Object 
     Public htmlUrl As Object 
     Public rssUrl As Object 
    End Structure 
<XmlRpcUrl("http://somesite.info/xmlrpc.php")> _ 
    Public Interface IWP 
     Inherits IXmlRpcProxy 

     <XmlRpcMethod("wp.getCategories")> _ 
     Function getCategories(ByVal args() As String) As category() 
    End Interface 
    Public Structure blogInfo 
     Public title As String 
     Public description As String 
    End Structure 

    Public Interface IgetCatList 
     <CookComputing.XmlRpc.XmlRpcMethod("metaWeblog.newPost")> _ 
     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 
    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 

    End Sub 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
     Dim proxy As IWP = XmlRpcProxyGen.Create(Of IWP)() 
     Dim args() As String = {"http://somesite.info", _ 
            "AdminUserName", "Password"} 
     Dim categories() As category 
     categories = proxy.getCategories(args) 
     For Each category In categories 
      Debug.Print(category.categoryId) 
      Debug.Print(category.categoryName) 
      Debug.Print(category.description) 
      Debug.Print(category.htmlUrl) 
      Debug.Print(category.rssUrl) 
     Next 

    End Sub 

    Private Sub btnPost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPost.Click 
     Dim newBlogPost As blogInfo = Nothing 
     newBlogPost.title = "The Title" 
     newBlogPost.description = "The Post Body Text" 
     Dim categories = CType(XmlRpcProxyGen.Create(GetType(IgetCatList)), IgetCatList) 
     Dim clientProtocol = CType(categories, XmlRpcClientProtocol) 
     clientProtocol.Url = "http://yoursite.com/xmlrpc.php" 
     Dim result As String = Nothing 
     result = "" 
     Try 
      result = categories.NewPage(1, "AdminUserName", "password", 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 
    End Sub 

End Class