XML RCP for Wordpress sites

  • Автор темы Автор темы Stroks
  • Дата начала Дата начала

Stroks

Client
Регистрация
09.02.2012
Сообщения
219
Реакции
14
Баллы
18
Does anyone have a XML-RCP code for posting to wordpress sites?

I have found these ones - http://stackoverflow.com/questions/9051912/send-post-tags-to-wordpress-within-xml-rpc and http://www.dotnetcurry.com/ShowArticle.aspx?ID=419 but i am not sure could they work, because there are some libraries for which I have no idea how to include in zennoposter C# ?

Is there anyone who cases to share a working solution. I guess someone uses this, because it is not possible that everyone post on wordpress blogs using slow manual method.
 
You don't need c# code to post to wordpress blogs. Just use HTTP POST using XML-RPC. All wordpress.com blogs come with it turned on.
 
Thanks.
I didn;t exactly understood how to do it. I have found HTTP POST under post request, but i do not see what is the RCP part or how to format the posts and is it possible to retrieve the url of the posted article?
 
Посмотреть вложение wp_post.xmlz

If your blog name is say bigcajones then in the POST action you would put http://bigcajones.wordpress.com/xmlrpc.php for the url. In the Data box you will put...

Код:
Развернуть Свернуть Копировать
?xml version="1.0" encoding="iso-8859-1"?>
<methodCall>
  <methodName>wp.newPost</methodName>
  <params>
    <param><value>1</value></param>
    <param><value>{-Variable.blog_username-}</value></param>
    <param><value>{-Variable.pass-}</value></param>
    <param>
      <value>
        <struct>
          <member><name>post_type</name>
            <value>post</value></member>
		<member><name>post_status</name>
            <value>publish</value></member>
		  <member><name>post_title</name>
            <value>{-Variable.title-}</value></member>
		  <member><name>post_content</name>
            <value><string>{-Variable.Content-}</string></value></member>
	          
      </struct></value>
    </param>
  </params>
</methodCall>

Replace the Variables with information you pull from your template. One note:* In your content if you have html you will have to replace the '<' and '>' respectively with '&lt;' and '&gt;' respecively since these are characters used for XML. If you have them in your content anywhere, the title will be posted but the content will not.

The POST will return XML with your blog post ID in it. All the info you need is found here...

Код:
Развернуть Свернуть Копировать
http://codex.wordpress.org/XML-RPC_WordPress_API
 
Последнее редактирование:
Awesome. This saves tons of time.



However the XML-RCP is completelly unusable, because it doesn't preserve HTML formatting. It can only post text and not links in WP 3.2.1.
 
I am getting this error response:


Код:
Развернуть Свернуть Копировать
HTTP/1.1 200 OK
Date: Mon, 13 May 2013 13:09:55 GMT
Server: LiteSpeed
Connection: close
X-Powered-By: PHP/5.3.23
Content-Type: text/xml
Content-Length: 386
Vary: User-Agent



<?xml version="1.0"?>
<methodResponse>
  <fault>
    <value>
      <struct>
        <member>
          <name>faultCode</name>
          <value><int>-32700</int></value>
        </member>
        <member>
          <name>faultString</name>
          <value><string>parse error. not well formed</string></value>
        </member>
      </struct>
    </value>
  </fault>
</methodResponse>

It seems not to work because I use WP 3.3 on my site.

Solution - if you use version of wordpress earlier than 3.4 use this XML

Код:
Развернуть Свернуть Копировать
<?xml version="1.0"?>
<methodCall>
  <methodName>metaWeblog.newPost</methodName>
  <params>
    <param>
      <value>
        <int>1</int>
      </value>
    </param>
    <param>
      <value>
        <string>{-Variable.Login-}</string>
      </value>
    </param>
    <param>
      <value>
        <string>{-Variable.Password-}</string>
      </value>
    </param>
    <struct>    
      <member>
        <name>title</name>
        <value><string>title</string></value>
      </member>
      <member>
        <name>description</name>
        <value><string>description</string></value>
      </member>
    </struct>  
    <param>
      <value>
        <bool>true</bool>
      </value>
    </param>    
  </params>  
</methodCall>

title = variable title
description = variable article
 
However the XML-RCP is completelly unusable, because it doesn't preserver HTML formatting. It can only post text and not links in WP 3.2.1.
 
delete this as well. Thanks.
 
Man this is really Great! Is there any way i can upload 3-4 images and insert them in the post?
 
I use this code for self hosted WP, and all works, only tags no. Is anybody know why tags not input?

<member>
<name>tags_input</name>
<value>tag1</value></member>
</struct></value>
 
  • Спасибо
Реакции: Шива
I found:

<member>
<name>mt_keywords</name>

<value>tag1,tag2</value></member>
 
Код:
Развернуть Свернуть Копировать
<?xml version="1.0" encoding="utf-8"?>
<methodCall>
<methodName>wp.newPost</methodName>
<params>
<param><value><string></string></value></param>
<param><value><string>login</string></value></param>
<param><value><string>password</string></value></param>
<param><value><struct>
  <member><name>post_title</name><value><string>tests</string></value></member>
  <member><name>post_content</name><value><string>test</string></value></member>
  <member><name>post_type</name><value><string>post</string></value></member>
<member><name>terms_names</name>
  <value>
    <struct>
        <member><name>category</name>
            <value><array>
                <data>
                    <value><string>yourcategoryname</string></value>
                </data>
            </array></value>
        </member>
    <member><name>post_tag</name>
            <value><array>
                <data>
                    <value><string>tag1, tag2, tag3</string></value>
                </data>
            </array></value>
        </member>
    </struct>
    </value>
</member>
  <member><name>terms</name><value><string></string></value></member>
  <member><name>custom_fields</name><value><array><data>
  <value><struct>
  <member><name>key</name><value><string>material_content</string></value></member>
  <member><name>value</name><value><string>100% Leather</string></value></member>
</struct></value>
  <value><struct>
  <member><name>key</name><value><string>fab_num</string></value></member>
  <member><name>value</name><value><string>11877</string></value></member>
</struct></value>
</data></array></value></member>
  <member><name>post_status</name><value><string>publish</string></value></member>
  <member><name>post_author</name><value><string></string></value></member>
  <member><name>post_password</name><value><string></string></value></member>
  <member><name>post_excerpt</name><value><string></string></value></member>
  <member><name>post_date</name><value><string></string></value></member>
  <member><name>post_date_gmt</name><value><string></string></value></member>
  <member><name>post_thumbnail</name><value><string></string></value></member>
  <member><name>comment_status</name><value><string></string></value></member>
  <member><name>ping_status</name><value><string></string></value></member>
  <member><name>post_format</name><value><string></string></value></member>
  <member><name>enclosure</name><value><string></string></value></member>
</struct></value></param>
</params></methodCall>

Working version + custom fields, categories, and other things.
 
  • Спасибо
Реакции: sergboss

Кто просматривает тему: (Всего: 0, Пользователи: 0, Гости: 0)