<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Patching WordPress xmlrpc to filter post using categories</title>
	<atom:link href="http://blogdodantas.dxs.com.br/2009/03/18/patching-wordpress-xmlrpc-to-filter-post-using-categories/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogdodantas.dxs.com.br/2009/03/18/patching-wordpress-xmlrpc-to-filter-post-using-categories/</link>
	<description>Tecnologia, segurança, cotidiano, pesca esportiva e inutilidades</description>
	<lastBuildDate>Wed, 08 Feb 2012 14:04:53 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
	<item>
		<title>By: Pierinux</title>
		<link>http://blogdodantas.dxs.com.br/2009/03/18/patching-wordpress-xmlrpc-to-filter-post-using-categories/comment-page-1/#comment-31645</link>
		<dc:creator>Pierinux</dc:creator>
		<pubDate>Mon, 06 Jun 2011 14:26:48 +0000</pubDate>
		<guid isPermaLink="false">http://blogdodantas.dxs.com.br/?p=238#comment-31645</guid>
		<description>Fantastic, it worked straight away. Thank you, you saved me lots of work.</description>
		<content:encoded><![CDATA[<p>Fantastic, it worked straight away. Thank you, you saved me lots of work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dee volume</title>
		<link>http://blogdodantas.dxs.com.br/2009/03/18/patching-wordpress-xmlrpc-to-filter-post-using-categories/comment-page-1/#comment-4793</link>
		<dc:creator>dee volume</dc:creator>
		<pubDate>Fri, 08 May 2009 18:32:07 +0000</pubDate>
		<guid isPermaLink="false">http://blogdodantas.dxs.com.br/?p=238#comment-4793</guid>
		<description>you know what, i hadn&#039;t changed everything from array elements to object properties of $entry as you had specified, so my fault! it works perfectly!
very grateful for this!</description>
		<content:encoded><![CDATA[<p>you know what, i hadn&#8217;t changed everything from array elements to object properties of $entry as you had specified, so my fault! it works perfectly!<br />
very grateful for this!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://blogdodantas.dxs.com.br/2009/03/18/patching-wordpress-xmlrpc-to-filter-post-using-categories/comment-page-1/#comment-4792</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Fri, 08 May 2009 18:18:01 +0000</pubDate>
		<guid isPermaLink="false">http://blogdodantas.dxs.com.br/?p=238#comment-4792</guid>
		<description>Apparently, you´ve done everything correctly. By the way, I´m copying my function here and then you can copy, paste and test.

Anyway, if you have a public url, I can make a call and test to see if it´s ok.

Cheers

&lt;code&gt;
function wp_getPostsByCategory($args){
	
		$this-&gt;escape($args);
		$catid = (int) $args[0];
		$username  = $args[1];
		$password  = $args[2];
		
		if ( !$this-&gt;login_pass_ok( $username, $password ) )
			return $this-&gt;error;
			
			
		do_action(&#039;xmlrpc_call&#039;, &#039;wp.getPostsByCategory&#039;);
		
		//$posts_list = get_posts(&#039;category=&#039;.$catid);
		$posts_list = get_posts(&#039;category=&#039;.$catid);
	
				
		if (!$posts_list) {
			return array( );
		}

		set_current_user( 0, $user_login );
	
		$i=0;
		foreach ($posts_list as $entry) {		

			setup_postdata($entry);
					
			//if( !current_user_can( &#039;edit_post&#039;, $entry-&gt;ID ) )
			//	continue;

			$post_date = mysql2date(&#039;Ymd\TH:i:s&#039;, $entry-&gt;post_date);
			$post_date_gmt = mysql2date(&#039;Ymd\TH:i:s&#039;, $entry-&gt;post_date_gmt);

			$tagnames = array();
			$tags = wp_get_post_tags( $entry-&gt;ID );
			if ( !empty( $tags ) ) {
				foreach ( $tags as $tag ) {
					$tagnames[] = $tag-&gt;name;
				}
				$tagnames = implode( &#039;, &#039;, $tagnames );
			} else {
				$tagnames = &#039;&#039;;
			}

			$post = get_extended($entry-&gt;post_content);
			$link = post_permalink($entry-&gt;ID);

			
			$allow_comments = (&#039;open&#039; == $entry-&gt;comment_status) ? 1 : 0;
			$allow_pings = (&#039;open&#039; == $entry-&gt;ping_status) ? 1 : 0;

			// Consider future posts as published
			if( $entry-&gt;post_status === &#039;future&#039; ) {
				$entry-&gt;post_status = &#039;publish&#039;;
			}

			$struct[] = array(
				&#039;dateCreated&#039; =&gt; new IXR_Date($post_date),
				&#039;userid&#039; =&gt; $entry-&gt;post_author,
				&#039;postid&#039; =&gt; $entry-&gt;ID,
				// usando content
				&#039;description&#039; =&gt; $post[&#039;main&#039;],
				&#039;title&#039; =&gt; $entry-&gt;post_title,
				&#039;link&#039; =&gt; $link,
				&#039;permaLink&#039; =&gt; $link,
				// commented out because no other tool seems to use this
				//&#039;content&#039; =&gt; $entry-&gt;post_content,
				&#039;categories&#039; =&gt; &#039;&#039;,
				&#039;mt_excerpt&#039; =&gt; $entry-&gt;post_excerpt,
				&#039;mt_text_more&#039; =&gt; $post-&gt;extended,
				&#039;mt_allow_comments&#039; =&gt; $allow_comments,
				&#039;mt_allow_pings&#039; =&gt; $allow_pings,
				&#039;mt_keywords&#039; =&gt; $tagnames,
				&#039;wp_slug&#039; =&gt; $entry-&gt;post_name,
				&#039;wp_password&#039; =&gt; $entry-&gt;post_password,
				&#039;wp_author_id&#039; =&gt; &#039;&#039;,
				&#039;wp_author_display_name&#039; =&gt; $author-&gt;display_name,
				&#039;date_created_gmt&#039; =&gt; new IXR_Date($post_date_gmt),
				&#039;post_status&#039; =&gt; $entry-&gt;post_status,
				&#039;custom_fields&#039; =&gt; $this-&gt;get_custom_fields($entry-&gt;ID)
			);

		}

		$recent_posts = array();
		for ($j=0; $j&lt;count($struct); $j++) {
			array_push($recent_posts, $struct[$j]);
		}
	
		//print_r($struct);

		return $recent_posts;
	
	}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Apparently, you´ve done everything correctly. By the way, I´m copying my function here and then you can copy, paste and test.</p>
<p>Anyway, if you have a public url, I can make a call and test to see if it´s ok.</p>
<p>Cheers</p>
<p><code><br />
function wp_getPostsByCategory($args){</p>
<p>		$this-&gt;escape($args);<br />
		$catid = (int) $args[0];<br />
		$username  = $args[1];<br />
		$password  = $args[2];</p>
<p>		if ( !$this-&gt;login_pass_ok( $username, $password ) )<br />
			return $this-&gt;error;</p>
<p>		do_action('xmlrpc_call', 'wp.getPostsByCategory');</p>
<p>		//$posts_list = get_posts('category='.$catid);<br />
		$posts_list = get_posts('category='.$catid);</p>
<p>		if (!$posts_list) {<br />
			return array( );<br />
		}</p>
<p>		set_current_user( 0, $user_login );</p>
<p>		$i=0;<br />
		foreach ($posts_list as $entry) {		</p>
<p>			setup_postdata($entry);</p>
<p>			//if( !current_user_can( 'edit_post', $entry-&gt;ID ) )<br />
			//	continue;</p>
<p>			$post_date = mysql2date('Ymd\TH:i:s', $entry-&gt;post_date);<br />
			$post_date_gmt = mysql2date('Ymd\TH:i:s', $entry-&gt;post_date_gmt);</p>
<p>			$tagnames = array();<br />
			$tags = wp_get_post_tags( $entry-&gt;ID );<br />
			if ( !empty( $tags ) ) {<br />
				foreach ( $tags as $tag ) {<br />
					$tagnames[] = $tag-&gt;name;<br />
				}<br />
				$tagnames = implode( ', ', $tagnames );<br />
			} else {<br />
				$tagnames = '';<br />
			}</p>
<p>			$post = get_extended($entry-&gt;post_content);<br />
			$link = post_permalink($entry-&gt;ID);</p>
<p>			$allow_comments = ('open' == $entry-&gt;comment_status) ? 1 : 0;<br />
			$allow_pings = ('open' == $entry-&gt;ping_status) ? 1 : 0;</p>
<p>			// Consider future posts as published<br />
			if( $entry-&gt;post_status === 'future' ) {<br />
				$entry-&gt;post_status = 'publish';<br />
			}</p>
<p>			$struct[] = array(<br />
				'dateCreated' =&gt; new IXR_Date($post_date),<br />
				'userid' =&gt; $entry-&gt;post_author,<br />
				'postid' =&gt; $entry-&gt;ID,<br />
				// usando content<br />
				'description' =&gt; $post['main'],<br />
				'title' =&gt; $entry-&gt;post_title,<br />
				'link' =&gt; $link,<br />
				'permaLink' =&gt; $link,<br />
				// commented out because no other tool seems to use this<br />
				//'content' =&gt; $entry-&gt;post_content,<br />
				'categories' =&gt; '',<br />
				'mt_excerpt' =&gt; $entry-&gt;post_excerpt,<br />
				'mt_text_more' =&gt; $post-&gt;extended,<br />
				'mt_allow_comments' =&gt; $allow_comments,<br />
				'mt_allow_pings' =&gt; $allow_pings,<br />
				'mt_keywords' =&gt; $tagnames,<br />
				'wp_slug' =&gt; $entry-&gt;post_name,<br />
				'wp_password' =&gt; $entry-&gt;post_password,<br />
				'wp_author_id' =&gt; '',<br />
				'wp_author_display_name' =&gt; $author-&gt;display_name,<br />
				'date_created_gmt' =&gt; new IXR_Date($post_date_gmt),<br />
				'post_status' =&gt; $entry-&gt;post_status,<br />
				'custom_fields' =&gt; $this-&gt;get_custom_fields($entry-&gt;ID)<br />
			);</p>
<p>		}</p>
<p>		$recent_posts = array();<br />
		for ($j=0; $j&lt;count($struct); $j++) {<br />
			array_push($recent_posts, $struct[$j]);<br />
		}</p>
<p>		//print_r($struct);</p>
<p>		return $recent_posts;</p>
<p>	}<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dee volume</title>
		<link>http://blogdodantas.dxs.com.br/2009/03/18/patching-wordpress-xmlrpc-to-filter-post-using-categories/comment-page-1/#comment-4791</link>
		<dc:creator>dee volume</dc:creator>
		<pubDate>Fri, 08 May 2009 16:04:54 +0000</pubDate>
		<guid isPermaLink="false">http://blogdodantas.dxs.com.br/?p=238#comment-4791</guid>
		<description>Hi Robson,
I&#039;m trying to employ some of what you&#039;ve written in order to do the same thing, but for a flash project
in terms of the xmlrpc.php  -
I&#039;m not sure if I&#039;ve totally understood the steps...

1 in xmlrpc.php I followed your step and added &#039;wp.getPostsByCategory&#039;   =&gt; &#039;this:wp_getPostsByCategory&#039;,
to the $this-methods array

but,
2 is where im not sure if im following you.
i copy/pasted the mw_getRecentPosts function, renamed my new function wp_getPostsByCategory, and amended the first few lines to use 

function wp_getPostsByCategory($args) {

		$this-&gt;escape($args);
		$blog_ID     = (int) $args[0];
		$user_login  = $args[1];
		$user_pass   = $args[2];
		$num_posts   = (int) $args[3];
		$cat   = (int) $args[4];

		if (!$this-&gt;login_pass_ok($user_login, $user_pass)) {
			return $this-&gt;error;
		}

		do_action(&#039;xmlrpc_call&#039;, &#039;wp.getPostsByCategory&#039;);

		$posts_list = get_posts( &quot;post_type=post&amp;post_status=all&amp;numberposts={$num_posts}&amp;category={$cat}&quot; );


after which, everything is the same as the original mw_getRecentPosts function



while my call to:
metaWeblog.getRecentPosts
worked succssfully calling my:
wp.getPostsByCategory
doesnt work :(

have i misunderstood what you wrote?

thanks!</description>
		<content:encoded><![CDATA[<p>Hi Robson,<br />
I&#8217;m trying to employ some of what you&#8217;ve written in order to do the same thing, but for a flash project<br />
in terms of the xmlrpc.php  -<br />
I&#8217;m not sure if I&#8217;ve totally understood the steps&#8230;</p>
<p>1 in xmlrpc.php I followed your step and added &#8216;wp.getPostsByCategory&#8217;   =&gt; &#8216;this:wp_getPostsByCategory&#8217;,<br />
to the $this-methods array</p>
<p>but,<br />
2 is where im not sure if im following you.<br />
i copy/pasted the mw_getRecentPosts function, renamed my new function wp_getPostsByCategory, and amended the first few lines to use </p>
<p>function wp_getPostsByCategory($args) {</p>
<p>		$this-&gt;escape($args);<br />
		$blog_ID     = (int) $args[0];<br />
		$user_login  = $args[1];<br />
		$user_pass   = $args[2];<br />
		$num_posts   = (int) $args[3];<br />
		$cat   = (int) $args[4];</p>
<p>		if (!$this-&gt;login_pass_ok($user_login, $user_pass)) {<br />
			return $this-&gt;error;<br />
		}</p>
<p>		do_action(&#8216;xmlrpc_call&#8217;, &#8216;wp.getPostsByCategory&#8217;);</p>
<p>		$posts_list = get_posts( &#8220;post_type=post&amp;post_status=all&amp;numberposts={$num_posts}&amp;category={$cat}&#8221; );</p>
<p>after which, everything is the same as the original mw_getRecentPosts function</p>
<p>while my call to:<br />
metaWeblog.getRecentPosts<br />
worked succssfully calling my:<br />
wp.getPostsByCategory<br />
doesnt work <img src='http://www.dxs.com.br/wordpress/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>have i misunderstood what you wrote?</p>
<p>thanks!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

