Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-06-27 09:36:52

bortzmeyer
Member
Registered: 2007-06-08
Posts: 14

A XML-RPC plugin?

I am looking for a XML-RPC (well, SOAP or REST could be OK, too) plugin to automate posts creation.

I found XRT:
http://textpattern.org/mods/225/xrt

But the download link is broken.

Anyone knows where to find XRT? Or another XML-RPC plugin?

Offline

#2 2007-06-27 09:42:45

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: A XML-RPC plugin?

You mean http://textpattern.com/download-rpc ?

It’s linked to on the textpattern download page.

Offline

#3 2007-06-27 10:06:26

bortzmeyer
Member
Registered: 2007-06-08
Posts: 14

Re: A XML-RPC plugin?

Sencer wrote:

You mean http://textpattern.com/download-rpc ?

Thanks, I don’t know how I missed it.

Two small more questions:

1) So, is XRT dead and should it be flagged as such in textpattern.org?

2) http://my.blog/rpc/ always reply:

XML-RPC server accepts POST requests only

but reading the session with WIreshark I can see that I do send a POST

Offline

#4 2007-06-27 13:10:41

Walker
Plugin Author
From: Boston, MA
Registered: 2004-02-24
Posts: 592
Website

Re: A XML-RPC plugin?

Uhh…..

if You see this: “XML-RPC server accepts POST requests only” you’re not using it with an XML-RPC client. Try MarsEdit or Ecto or w.bloggar.

Offline

#5 2007-06-27 19:39:57

bortzmeyer
Member
Registered: 2007-06-08
Posts: 14

Re: A XML-RPC plugin?

Walker wrote:

if You see this: “XML-RPC server accepts POST requests only” you’re not using it with an XML-RPC client.

I tried with a XML-RPC client (a Python program I wrote and which just calls system.listMethods).

As I already wrote, I sniffed the network with Wireshark and my program did send a POST.

Offline

#6 2007-06-27 20:08:05

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: A XML-RPC plugin?

we use $HTTP_RAW_POST_DATA in the server part. You should check if you have any settings on our server/php-config that might prevent it from being populated.

Also: If you are posting multipart/form-data-encoded messages that may well be the reason. Use application/x-www-form-urlencoded instead.

Offline

#7 2007-07-03 15:40:43

bortzmeyer
Member
Registered: 2007-06-08
Posts: 14

Re: A XML-RPC plugin?

bortzmeyer wrote:

I tried with a XML-RPC client (a Python program I wrote and which just calls system.listMethods).

The XML-RPC debugger (http://gggeek.raprap.it/debugger/) has the same problem:

—-GOT—-
HTTP/1.1 200 OK
Date: Tue, 03 Jul 2007 15:36:27 GMT
Server: Apache/2.0.58 (Gentoo) mod_python/3.2.10 Python/2.4.3 mod_ssl/2.0.58 OpenSSL/0.9.8d PHP/5.2.2-pl1-gentoo mod_perl/2.0.3-dev Perl/v5.8.8
X-Powered-By: PHP/5.2.2-pl1-gentoo
Content-Length: 42
Connection: close
Content-Type: text/html

XML-RPC server accepts POST requests only.
—-END—-

HEADER: date: Tue, 03 Jul 2007 15:36:27 GMT
HEADER: server: Apache/2.0.58 (Gentoo) mod_python/3.2.10 Python/2.4.3 mod_ssl/2.0.58 OpenSSL/0.9.8d PHP/5.2.2-pl1-gentoo mod_perl/2.0.3-dev Perl/v5.8.8
HEADER: x-powered-by: PHP/5.2.2-pl1-gentoo
HEADER: content-length: 42
HEADER: connection: close
HEADER: content-type: text/html

XML error at line 1, check URL

Offline

#8 2007-07-03 15:49:56

bortzmeyer
Member
Registered: 2007-06-08
Posts: 14

Re: A XML-RPC plugin?

Sencer wrote:

If you are posting multipart/form-data-encoded messages that may well be the reason. Use application/x-www-form-urlencoded instead.

I do not understand, the spec (http://www.xmlrpc.com/spec) says I should use text/xml and this is what I send:

% python client.py
connect: (blog.demaziere.fr, 80)
send: ‘POST /rpc/ HTTP/1.0\r\nHost: blog.demaziere.fr\r\nAuthorization: Basic XXXXXXXXXXX==\r\nUser-Agent: xmlrpclib.py/1.0.1 (by www.pythonware.com)\r\nContent-Type: text/xml\r\nContent-Length: 112\r\n\r\n’
send: “<?xml version=‘1.0’?>\n<methodCall>\n<methodName>system.listMethods</methodName>\n<params>\n</params>\n</methodCall>\n”
reply: ‘HTTP/1.1 200 OK\r\n’
header: Date: Tue, 03 Jul 2007 15:47:37 GMT
header: Server: Apache/2.0.58 (Gentoo) mod_python/3.2.10 Python/2.4.3 mod_ssl/2.0.58 OpenSSL/0.9.8d PHP/5.2.2-pl1-gentoo mod_perl/2.0.3-dev Perl/v5.8.8
header: X-Powered-By: PHP/5.2.2-pl1-gentoo
header: Content-Length: 42
header: Connection: close
header: Content-Type: text/html
body: ‘XML-RPC server accepts POST requests only.’

Offline

#9 2007-07-03 17:49:55

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: A XML-RPC plugin?

First, try to to use a regular xml-rpc client (the blogging-type thingies) to see if the problem is with your client at all, or whether it is a server-issue. It may be that for some other reason the server is not populating
$HTTP_RAW_POST_DATA which would lead to the error you are seeing.

Check:
http://de3.php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data

If it doesn’t even work with a regular xmlroc client, then it’s probably something serverside rather than your client that’s the issue.

Offline

#10 2007-07-03 19:49:53

bortzmeyer
Member
Registered: 2007-06-08
Posts: 14

Re: A XML-RPC plugin?

Sencer wrote:

It may be that for some other reason the server is not populating $HTTP_RAW_POST_DATA which would lead to the error you are seeing.
Check: http://de3.php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data

always_populate_raw_post_data is On (tested with phpinfo()). Content-type is text/xml. According to the PHP documentation, HTTP_RAW_POST_DATA should be set but is not.

I googled a lot about HTTP_RAW_POST_DATA and it seems not advised to use this variable?

I tried the technique mentioned in bug 22338 and it works! My XML-RPC client is now accepted. (And the XML-RPC debugger as well.)

Here is the patch:

--- TXP_RPCServer.php.orig      2007-07-03 21:28:31.000000000 +0200
+++ TXP_RPCServer.php   2007-07-03 21:26:07.000000000 +0200
@@ -178,9 +178,11 @@
         if (!$data) {
             global $HTTP_RAW_POST_DATA;            

-            if (!$HTTP_RAW_POST_DATA) {
-               die('XML-RPC server accepts POST requests only.');
-            }            
+               if (isset($HTTP_RAW_POST_DATA)) {
+                   $input = $HTTP_RAW_POST_DATA;
+               } else {
+                   $input = implode("\r\n", file('php://input'));
+               }

             $rx = '/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m';            

@@ -188,10 +190,10 @@
                if (strpos('w.bloggar',$_SERVER['HTTP_USER_AGENT'])!==false){
                        $encoding = 'iso-8859-1';
                # find for supplied encoding before to try other things
-               }elseif (preg_match($rx, $HTTP_RAW_POST_DATA, $xml_enc)) {
+               }elseif (preg_match($rx, $input, $xml_enc)) {
                                $encoding = strtolower($xml_enc[1]);
                        # try utf-8 detect
-                       }elseif(preg_match('/^([\x00-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0               -\xbf][\x80-\xbf]|[\xe1-\xec][\x80-\xbf]{2}|\xed[\x80-\x9f][\x80-\xbf]|[\xee-\xef][\x80-\xb               f]{2}|f0[\x90-\xbf][\x80-\xbf]{2}|[\xf1-\xf3][\x80-\xbf]{3}|\xf4[\x80-\x8f][\x80-\xbf]{2})*               $/', $HTTP_RAW_POST_DATA) === 1) {
+                       }elseif(preg_match('/^([\x00-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0               -\xbf][\x80-\xbf]|[\xe1-\xec][\x80-\xbf]{2}|\xed[\x80-\x9f][\x80-\xbf]|[\xee-\xef][\x80-\xb               f]{2}|f0[\x90-\xbf][\x80-\xbf]{2}|[\xf1-\xf3][\x80-\xbf]{3}|\xf4[\x80-\x8f][\x80-\xbf]{2})*               $/', $input) === 1) {
                                $encoding = 'utf-8';
                        # otherwise, use iso-8859-1
                        }else {
@@ -201,15 +203,15 @@
             switch ($encoding)
             {
                case 'utf-8':
-                       $data = $HTTP_RAW_POST_DATA;
+                       $data = $input;
                break;
                case 'iso-8859-1':
                        # this will fails on parser if utf8_encode is unavailiable
-                       $data = (function_exists('utf8_encode') && is_callable('utf8_encode               '))? utf8_encode($HTTP_RAW_POST_DATA) : $HTTP_RAW_POST_DATA;
+                       $data = (function_exists('utf8_encode') && is_callable('utf8_encode               '))? utf8_encode($input) : $input;
                break;
                default:
                        # this will fails on parser if mb_convert_encoding is unavailiable
-                       $data = (function_exists('mb_convert_encoding') && is_callable('mb_               convert_encoding'))? mb_convert_encoding($HTTP_RAW_POST_DATA, 'utf-8', $encoding) : $HTTP_R               AW_POST_DATA;
+                       $data = (function_exists('mb_convert_encoding') && is_callable('mb_               convert_encoding'))? mb_convert_encoding($input, 'utf-8', $encoding) : $input;
                break;
             }

Offline

#11 2007-07-03 21:21:05

bortzmeyer
Member
Registered: 2007-06-08
Posts: 14

Re: A XML-RPC plugin?

bortzmeyer wrote:

I tried the technique mentioned in bug 22338 and it works! My XML-RPC client is now accepted. (And the XML-RPC debugger as well.)

Gaetano Giunta has a simpler suggestion, taken from bug 41293, just add at the beginning of the routine:

if (!isset($HTTP_RAW_POST_DATA)){
   $HTTP_RAW_POST_DATA = file_get_contents('php://input');
}

Offline

#12 2007-07-04 07:10:18

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: A XML-RPC plugin?

bortzmeyer, thanks a lot. Your feedback is much appreciated. :)

Offline

Board footer

Powered by FluxBB