<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SharpLab. &#187; XML-RPCCLib</title>
	<atom:link href="http://blog.sharplab.net/category/computer/cprograming/xml-rpcclib/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sharplab.net</link>
	<description>Shiroicaが学び、経験したことを綴る個人サイト。</description>
	<lastBuildDate>Thu, 12 Jan 2012 00:57:03 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>XMLRPCでeval</title>
		<link>http://blog.sharplab.net/blog/2008/12/05/1401/</link>
		<comments>http://blog.sharplab.net/blog/2008/12/05/1401/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 12:24:24 +0000</pubDate>
		<dc:creator>shiroica</dc:creator>
				<category><![CDATA[XML-RPCCLib]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[XML-RPC]]></category>

		<guid isPermaLink="false">http://blog.sharplab.net/computer/cprograming/xml-rpcclib/1401/</guid>
		<description><![CDATA[今回もWordPressのXML-RPCについて。但し、今回はサーバーサイドのお話。XML-RPCを使うと、WordPressのエントリやコメントなどを外部のプログラムから弄ることが出来てなかなか便利ですが、アクセスできるのはあくまでもXML-RPCのメソッドとして公開されている部分だけです。自分でメソッドを追加できたらなー。寧ろ任意のPHPスクリプトを実行できたら便利じゃね？ということで、引数として渡したPHPコードをeval関数で評価した結果を返すXML-RPCサーバーをxmlrpc.phpを改変して作ってみました。思いつきで試しに書いてみただけなので、プラグインとして纏まっていないのはご愛嬌。customrpc.phpとでも名前をつけて、xmlrpc.phpと同じディレクトリに配置すると動きます。 &#60;?php /** * Custom RPC Server * created by shiroica * @license GPL v2 &#60;./license.txt&#62; * Most of this code is based on "xmlrpc.php" file of WordPress. */ /** * Whether this is a XMLRPC Request * * @var bool */ define('XMLRPC_REQUEST', true); // Some browser-embedded clients send cookies. We don't want them. $_COOKIE [...]]]></description>
			<content:encoded><![CDATA[<p>今回もWordPressのXML-RPCについて。但し、今回はサーバーサイドのお話。XML-RPCを使うと、WordPressのエントリやコメントなどを外部のプログラムから弄ることが出来てなかなか便利ですが、アクセスできるのはあくまでもXML-RPCのメソッドとして公開されている部分だけです。自分でメソッドを追加できたらなー。寧ろ任意のPHPスクリプトを実行できたら便利じゃね？ということで、引数として渡したPHPコードをeval関数で評価した結果を返すXML-RPCサーバーをxmlrpc.phpを改変して作ってみました。思いつきで試しに書いてみただけなので、プラグインとして纏まっていないのはご愛嬌。customrpc.phpとでも名前をつけて、xmlrpc.phpと同じディレクトリに配置すると動きます。</p>
<p>
<div class="wlWriterEditableSmartContent" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:d8ddc28f-2d4c-4a18-ad44-976f99cbd509" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre name="code" class="php">&lt;?php
/**
 * Custom RPC Server
 * created by shiroica
 * @license GPL v2 &lt;./license.txt&gt;
 * Most of this code is based on "xmlrpc.php" file of WordPress.
 */

/**
 * Whether this is a XMLRPC Request
 *
 * @var bool
 */
define('XMLRPC_REQUEST', true);

// Some browser-embedded clients send cookies. We don't want them.
$_COOKIE = array();

// A bug in PHP &lt; 5.2.2 makes $HTTP_RAW_POST_DATA not set by default,
// but we can do it ourself.
if ( !isset( $HTTP_RAW_POST_DATA ) ) {
	$HTTP_RAW_POST_DATA = file_get_contents( 'php://input' );
}

// fix for mozBlog and other cases where '&lt;?xml' isn't on the very first line
if ( isset($HTTP_RAW_POST_DATA) )
	$HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA);

/** Include the bootstrap for setting up WordPress environment */
include('./wp-load.php');

include_once(ABSPATH . 'wp-admin/includes/admin.php');
include_once(ABSPATH . WPINC . '/class-IXR.php');

// Turn off all warnings and errors.
// error_reporting(0);

/**
 * Posts submitted via the xmlrpc interface get that title
 * @name post_default_title
 * @var string
 */
$post_default_title = "";

/**
 * Whether to enable XMLRPC Logging.
 *
 * @name xmlrpc_logging
 * @var int|bool
 */
$xmlrpc_logging = 0;

/**
 * logIO() - Writes logging info to a file.
 *
 * @uses $xmlrpc_logging
 * @package WordPress
 * @subpackage Logging
 *
 * @param string $io Whether input or output
 * @param string $msg Information describing logging reason.
 * @return bool Always return true
 */
function logIO($io,$msg) {
	global $xmlrpc_logging;
	if ($xmlrpc_logging) {
		$fp = fopen("../xmlrpc.log","a+");
		$date = gmdate("Y-m-d H:i:s ");
		$iot = ($io == "I") ? " Input: " : " Output: ";
		fwrite($fp, "nn".$date.$iot.$msg);
		fclose($fp);
	}
	return true;
}

if ( isset($HTTP_RAW_POST_DATA) )
	logIO("I", $HTTP_RAW_POST_DATA);

/**
 * error2ExceptionConverter - handle an error and throw it as an exception.
 */
function error2ExceptionConverter($errno, $errstr, $errfile, $errline) {
	throw new Exception($errstr, $errno);
}

/**
 * XMLRPC server implementation that enables users to evaluate passed PHP code.
 */
class custom_rpc_server extends IXR_Server {

	/**
	 * Register all of the XMLRPC methods that XMLRPC server understands.
	 *
	 * PHP4 constructor and sets up server and method property. Passes XMLRPC
	 * methods through the 'xmlrpc_methods' filter to allow plugins to extend
	 * or replace XMLRPC methods.
	 *
	 * @since 1.5.0
	 *
	 * @return wp_xmlrpc_server
	 */
	function custom_rpc_server() {
		$this-&gt;methods = array(
			'eval' =&gt; 'this:callEval'
		);
		$this-&gt;methods = apply_filters('xmlrpc_methods', $this-&gt;methods);
		$this-&gt;IXR_Server($this-&gt;methods);
	}

	/**
	 * Evaluate passed PHP code by "eval()" function.
	 * @param array $args Method Parameters.
	 * @return depends "eval()" function returned.
	 */
	function callEval($args) {

		$user_login = $this-&gt;escape($args[0]);
		$user_pass  = $this-&gt;escape($args[1]);
		$code_str   = $args[2];

		set_current_user( 0, $user_login );
		if( !current_user_can( 'edit_posts' ) )
			return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this blog.' ) );

		if (!$this-&gt;login_pass_ok($user_login, $user_pass)) {
			return $this-&gt;error;
		}
		set_error_handler('error2ExceptionConverter');
		try{
			@$result = eval($code_str);
		}
		catch(Exception $exception){
			restore_error_handler();
			return new IXR_Error( 500, __( 'Runtime error was occurred while executing your code.' ) );
		}
		restore_error_handler();
		if($result === false){
			return new IXR_Error( 500, __( 'Parse error was occurred while executing your code.' ) );
		}
		return $result;
	}

	/**
	 * Check user's credentials.
	 *
	 * @since 1.5.0
	 *
	 * @param string $user_login User's username.
	 * @param string $user_pass User's password.
	 * @return bool Whether authentication passed.
	 */
	function login_pass_ok($user_login, $user_pass) {
		if ( !get_option( 'enable_xmlrpc' ) ) {
			$this-&gt;error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this blog.  An admin user can enable them at %s'),  admin_url('options-writing.php') ) );
			return false;
		}

		if (!user_pass_ok($user_login, $user_pass)) {
			$this-&gt;error = new IXR_Error(403, __('Bad login/pass combination.'));
			return false;
		}
		return true;
	}

	/**
	 * Sanitize string or array of strings for database.
	 *
	 * @since 1.5.2
	 *
	 * @param string|array $array Sanitize single string or array of strings.
	 * @return string|array Type matches $array and sanitized for the database.
	 */
	function escape(&amp;$array) {
		global $wpdb;

		if(!is_array($array)) {
			return($wpdb-&gt;escape($array));
		}
		else {
			foreach ( (array) $array as $k =&gt; $v ) {
				if (is_array($v)) {
					$this-&gt;escape($array[$k]);
				} else if (is_object($v)) {
					//skip
				} else {
					$array[$k] = $wpdb-&gt;escape($v);
				}
			}
		}
	}
}

$custom_rpc_server = new custom_rpc_server();

?&gt;
</pre>
</div>
<p>ユーザー名、パスワード、評価させたいPHPコードを引数として渡すと、評価された結果が帰ってきます。戻り値は<a href="http://scripts.incutio.com/xmlrpc/">The Incutio XML-RPC Library for PHP</a>でパースできるデータ型で構成されていないとまずいかも。自分でも全然使っていないからよく分からない（笑）。あと、eval関数の都合上、戻り値がfalseだと実行時エラーと区別がつかないので、戻り値はbool型はやめましょう。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sharplab.net/blog/2008/12/05/1401/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress 2.7 Comment APIについての備忘録。</title>
		<link>http://blog.sharplab.net/blog/2008/10/26/1291/</link>
		<comments>http://blog.sharplab.net/blog/2008/10/26/1291/#comments</comments>
		<pubDate>Sat, 25 Oct 2008 16:59:44 +0000</pubDate>
		<dc:creator>shiroica</dc:creator>
				<category><![CDATA[XML-RPCCLib]]></category>
		<category><![CDATA[Comment API]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[XML-RPC]]></category>

		<guid isPermaLink="false">http://blog.sharplab.net/computer/cprograming/xml-rpcclib/1291/</guid>
		<description><![CDATA[WordPressの開発版、2.7-almost-beta-9300をXAMPP上に入れてみました。メニューの配置が変わったりと、UIに結構手が入れられたのが2.7一番のポイントですが、それで物凄く使いやすくなったかというと、別にそうでもないというのが自分の受けた印象。まぁ、長く使っていくうちにじわじわと道具としての良さが分かってくるのかもしれないですが。 さて、WP2.7の重要な新機能の一つである、Comment APIをちょっと調べてみました。 2.7からはコメントをXMLRPCを通じて編集出来るようになりました。この機能をWPではComment APIとして呼ぶのですが、具体的には以下に引用した通りのメソッドが実装されています。 http://trac.wordpress.org/ticket/7446 Latest patch: http://trac.wordpress.org/attachment/ticket/7446/7446.9.diff The following methods are implemented: wp.getComment(blog_id, username, password, comment_id) wp.getComments(blog_id, username, password, {status, post_id, number, offset} wp.deleteComment(blog_id, username, password, comment_id) wp.editComment(blog_id, username, password, comment_id, {status, date_created_gmt, content, author, author_url, author_email, }) wp.newComment(blog_id, username, password, post, {content, author, author_email, author_url}) // author info is optional if authorization [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.sharplab.net/wp-content/uploads/2008/10/image15.png" rel="lightbox"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; margin-left: 0px; border-left: 0px; margin-right: 0px; border-bottom: 0px" height="188" alt="image" src="http://blog.sharplab.net/wp-content/uploads/2008/10/image-thumb12.png" width="404" align="left" border="0" /></a> </p>
<p>WordPressの開発版、2.7-almost-beta-9300をXAMPP上に入れてみました。メニューの配置が変わったりと、UIに結構手が入れられたのが2.7一番のポイントですが、それで物凄く使いやすくなったかというと、別にそうでもないというのが自分の受けた印象。まぁ、長く使っていくうちにじわじわと道具としての良さが分かってくるのかもしれないですが。</p>
<p>さて、WP2.7の重要な新機能の一つである、Comment APIをちょっと調べてみました。    <br />2.7からはコメントをXMLRPCを通じて編集出来るようになりました。この機能をWPではComment APIとして呼ぶのですが、具体的には以下に引用した通りのメソッドが実装されています。</p>
<blockquote><p>http://trac.wordpress.org/ticket/7446      </p>
<p>Latest patch:       </p>
<p>http://trac.wordpress.org/attachment/ticket/7446/7446.9.diff       </p>
<p>The following methods are implemented:       </p>
<p>wp.getComment(blog_id, username, password, comment_id)       </p>
<p>wp.getComments(blog_id, username, password, {status, post_id, number, offset}       </p>
<p>wp.deleteComment(blog_id, username, password, comment_id)       </p>
<p>wp.editComment(blog_id, username, password, comment_id, {status,       <br />date_created_gmt, content, author, author_url, author_email, })       </p>
<p>wp.newComment(blog_id, username, password, post, {content, author,       <br />author_email, author_url})       <br />// author info is optional if authorization is successful.       <br />Unregistered commenting is allowed if a plugin sets the       <br />xmlrpc_allow_anonymous_comments filter to true. Default is to not       <br />allow unregistered comments. User must auth.       </p>
<p>wp.getCommentStatusList(blog_id, username, password)       </p>
<p>   <cite><a href="http://comox.textdrive.com/pipermail/wp-xmlrpc/2008-August/000258.html">[wp-xmlrpc] Comments API</a> </cite></p></blockquote>
<p>で、これらの中で注意が必要なのが、wp.newCommentメソッド。引用文中に</p>
<blockquote><p>author info is optional if authorization is successful.</p>
</blockquote>
<p>というコメントが入っていますが、認証に通っている場合、実はauthorやauthor_emailに指定した値は無視され、使用されません。WPのユーザーアカウント情報の対応する値が使用されることに注意しましょう。以上のことは、xmlrpc.phpの1275行目で確認できます。</p>
<div class="wlWriterSmartContent" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:65b28085-cc3c-4e3e-969d-41ee8fc7f2ea" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre name="code" class="php:firstline[1275]">		if ( $logged_in ) {
			$user = wp_get_current_user();
			$comment['comment_author'] = $wpdb-&gt;escape( $user-&gt;display_name );
			$comment['comment_author_email'] = $wpdb-&gt;escape( $user-&gt;user_email );
			$comment['comment_author_url'] = $wpdb-&gt;escape( $user-&gt;user_url );
			$comment['user_ID'] = $user-&gt;ID;
		} else {
</pre>
</div>
<p>では認証を通さなければ、一般ビジターとして好きなメルアドやURLを指定してコメントをつけられるかというと、そうでもなくて、今度は</p>
<blockquote>
<p>Unregistered commenting is allowed if a plugin sets the xmlrpc_allow_anonymous_comments filter to true.</p>
</blockquote>
<p>という問題に引っかかります。ままならないものですね…。</p>
<p>あと気になった点といえば、同一内容のコメントを連投しようとした場合、Response Code 500で撥ねられるという点。XMLRPC経由なのだから、XMLRPC Faultでエラーを通知するべきだと思うのですが…。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sharplab.net/blog/2008/10/26/1291/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WP-XMLRPCのパースエラーのデモンストレーション用コード</title>
		<link>http://blog.sharplab.net/blog/2008/10/19/1285/</link>
		<comments>http://blog.sharplab.net/blog/2008/10/19/1285/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 14:46:11 +0000</pubDate>
		<dc:creator>shiroica</dc:creator>
				<category><![CDATA[XML-RPCCLib]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[XML-RPC]]></category>

		<guid isPermaLink="false">http://blog.sharplab.net/computer/cprograming/xml-rpcclib/1285/</guid>
		<description><![CDATA[折角なので昨日のWordPressにXML-RPC経由でサイズの大きなファイルを送信する際にパースエラーが発生した場合の対処法 &#8211; SharpLab.というエントリの現象を確認するためのデモンストレーション用コードを公開しておきます。 WordPressXmlrpcErrorDemonstration.zip 実行に先立っては、WordPressのログイン情報等を適宜書き加える必要があります。 namespace WordPressXmlrpcErrorDemonstration { public partial class Form1 : Form { private const string _hostName = "";//テスト用WordPressのXMLRPCエンドポイントURLを指定のこと private const string _userAgent = "WordPressXmlrpcErrorDemonstration"; private const string USERNAME = "";//テスト用WordPressのユーザー名を指定のこと private const string PASSWORD = "";//テスト用WordPressのパスワードを指定のこと また、XMLRPC応答は35行目のresponseという変数に収められます。 XmlRpcMethodResponse response = client.CallMethod("wp.uploadFile", addXMLDeclaration, new XmlRpcInt(0), new XmlRpcString(USERNAME), new XmlRpcString(PASSWORD), new XmlRpcStruct(new XmlRpcStructMember[]{ new [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.sharplab.net/wp-content/uploads/2008/10/image13.png" rel="lightbox"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin-left: 0px; margin-right: 0px; border-right-width: 0px" height="127" alt="image" src="http://blog.sharplab.net/wp-content/uploads/2008/10/image-thumb10.png" width="254" align="right" border="0" /></a> 折角なので昨日の<a href="http://blog.sharplab.net/computer/cprograming/xml-rpcclib/1281/">WordPressにXML-RPC経由でサイズの大きなファイルを送信する際にパースエラーが発生した場合の対処法 &#8211; SharpLab.</a>というエントリの現象を確認するためのデモンストレーション用コードを公開しておきます。</p>
<p><a href="http://depot.sharplab.net/CSharp/XMLRPC/WordPressXmlrpcErrorDemonstration.zip">WordPressXmlrpcErrorDemonstration.zip</a></p>
<p>実行に先立っては、WordPressのログイン情報等を適宜書き加える必要があります。</p>
<div class="wlWriterSmartContent" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:80489e63-cc01-4bc1-9eae-826533c3b2de" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre name="code" class="c#:firstline[11]">namespace WordPressXmlrpcErrorDemonstration {
	public partial class Form1 : Form {

		private const string _hostName = "";//テスト用WordPressのXMLRPCエンドポイントURLを指定のこと
		private const string _userAgent = "WordPressXmlrpcErrorDemonstration";
		private const string USERNAME = "";//テスト用WordPressのユーザー名を指定のこと
		private const string PASSWORD = "";//テスト用WordPressのパスワードを指定のこと
</pre>
</div>
<p>また、XMLRPC応答は35行目のresponseという変数に収められます。</p>
<div class="wlWriterSmartContent" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:c5e32bb8-8457-4344-b2c1-adb8106f073f" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre name="code" class="c#:firstline[35]">XmlRpcMethodResponse response = client.CallMethod("wp.uploadFile", addXMLDeclaration,
    new XmlRpcInt(0),
    new XmlRpcString(USERNAME),
    new XmlRpcString(PASSWORD),
    new XmlRpcStruct(new XmlRpcStructMember[]{
        new XmlRpcStructMember("name",new XmlRpcString(file.Name)),
        new XmlRpcStructMember("type",new XmlRpcString("")),
        new XmlRpcStructMember("bits",new XmlRpcBase64(bytes)),
        new XmlRpcStructMember("overwrite",new XmlRpcBoolean(false))
    }));</pre>
</div>
<p>ところでこのプロジェクトではCompact Framework向けにビルドしたライブラリを特に弄ることなく参照しているのですが、問題ないのですかね？とりあえず普通に動いているようなのですが…。.Net Compact Frameworkと.Net Frameworkの関係がいまいち分からない。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sharplab.net/blog/2008/10/19/1285/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPressにXML-RPC経由でサイズの大きなファイルを送信する際にパースエラーが発生した場合の対処法</title>
		<link>http://blog.sharplab.net/blog/2008/10/18/1281/</link>
		<comments>http://blog.sharplab.net/blog/2008/10/18/1281/#comments</comments>
		<pubDate>Sat, 18 Oct 2008 09:28:37 +0000</pubDate>
		<dc:creator>shiroica</dc:creator>
				<category><![CDATA[XML-RPCCLib]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[XML-RPC]]></category>

		<guid isPermaLink="false">http://blog.sharplab.net/computer/cprograming/xml-rpcclib/1281/</guid>
		<description><![CDATA[最近Compact Framework用XML-RPCクライアントライブラリを書いているのですが、WordPress XML-RPC APIのwp.uploadFileメソッドを使ってファイルを送信しようとした場合、パースエラーが発生する現象に悩まされました。ファイルが小さい場合は問題がないのですが、ファイルのサイズが大きくなるとパースエラーを返すという現象です。 調べてみたところ、WordPressのXML-RPC関係の処理を担っているIncutio XML-RPC Library for PHPがどうやら問題の原因のようで、class-IXR.php（wp-includes以下にあります）で定義されているIXR_Messageクラスのparseメソッドのところでエラーが返されているようです。 function parse() { // first remove the XML declaration $this-&#62;message = preg_replace('/&#60;?xml(.*)??'.'&#62;/', '', $this-&#62;message); if (trim($this-&#62;message) == '') { return false; } //以下省略 どうもエラーが起きる場合は157行目を境に$this-&#62;messageの内容が空になっているようで、それが原因で159行目でreturn falseされてしまっているようです。なぜファイルが大きい場合だけそのようなことになるのかはちょっとよく分からないのですが（不適切な正規表現なのでしょうか？）、とりあえずPOSTするXMLからXML宣言を削除し、methodCall要素以下だけのXMLフラグメントとして送信するようにしたところ上手くいくようになりました。参考まで。 追記： WP-XMLRPCのパースエラーのデモンストレーション用コード &#8211; SharpLab.を書きました。]]></description>
			<content:encoded><![CDATA[<p>最近Compact Framework用XML-RPCクライアントライブラリを書いているのですが、WordPress XML-RPC APIのwp.uploadFileメソッドを使ってファイルを送信しようとした場合、パースエラーが発生する現象に悩まされました。ファイルが小さい場合は問題がないのですが、ファイルのサイズが大きくなるとパースエラーを返すという現象です。</p>
<p>調べてみたところ、WordPressのXML-RPC関係の処理を担っている<a href="http://scripts.incutio.com/xmlrpc/">Incutio XML-RPC Library for PHP</a>がどうやら問題の原因のようで、class-IXR.php（wp-includes以下にあります）で定義されているIXR_Messageクラスのparseメソッドのところでエラーが返されているようです。</p>
<div class="wlWriterSmartContent" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:75e908c3-707f-44e3-b475-13b75bda2f46" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre name="code" class="php:firstline[155]">function parse() {
    // first remove the XML declaration
    $this-&gt;message = preg_replace('/&lt;?xml(.*)??'.'&gt;/', '', $this-&gt;message);
    if (trim($this-&gt;message) == '') {
        return false;
    }
//以下省略</pre>
</div>
<p>どうもエラーが起きる場合は157行目を境に$this-&gt;messageの内容が空になっているようで、それが原因で159行目でreturn falseされてしまっているようです。なぜファイルが大きい場合だけそのようなことになるのかはちょっとよく分からないのですが（不適切な正規表現なのでしょうか？）、とりあえずPOSTするXMLからXML宣言を削除し、methodCall要素以下だけのXMLフラグメントとして送信するようにしたところ上手くいくようになりました。参考まで。</p>
<p>追記：</p>
<p><a href="http://blog.sharplab.net/computer/cprograming/xml-rpcclib/1285/">WP-XMLRPCのパースエラーのデモンストレーション用コード &#8211; SharpLab.</a>を書きました。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sharplab.net/blog/2008/10/18/1281/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

