<?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>AB-WebLog.com&#187; PHP</title>
	<atom:link href="http://www.ab-weblog.com/en/category/development/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ab-weblog.com/en</link>
	<description>Andreas Breitschopp</description>
	<lastBuildDate>Wed, 18 Mar 2015 09:47:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>WordPress Multisite: Redirect Users Based on Their Browser Language</title>
		<link>http://www.ab-weblog.com/en/wordpress-multisite-redirect-users-based-on-their-browser-language/</link>
		<comments>http://www.ab-weblog.com/en/wordpress-multisite-redirect-users-based-on-their-browser-language/#comments</comments>
		<pubDate>Fri, 22 Jun 2012 16:44:12 +0000</pubDate>
		<dc:creator>Andreas Breitschopp</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[multilingual]]></category>
		<category><![CDATA[multisite]]></category>
		<category><![CDATA[plug-in]]></category>

		<guid isPermaLink="false">http://www.ab-weblog.com/en/?p=502</guid>
		<description><![CDATA[Since I wrote the post about using the Multisite Language Switcher I got many questions asking how I &#8220;disabled&#8221; the main site &#8220;/&#8221; in my WordPress Multisite configuration. The answer is simple: I did not disable it, but just created an &#8230; <a href="http://www.ab-weblog.com/en/wordpress-multisite-redirect-users-based-on-their-browser-language/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Since I wrote the post about using the <a title="The Solution for Multilingual Blogs in WordPress" href="http://www.ab-weblog.com/en/the-solution-for-multilingual-blogs-in-wordpress/">Multisite Language Switcher</a> I got many questions asking how I &#8220;disabled&#8221; the main site &#8220;/&#8221; in my WordPress Multisite configuration.</p>
<p>The answer is simple: I did not disable it, but just created an own, small redirect theme to make sure every user accessing the main site &#8220;/&#8221; is redirected to the correct language URL &#8211; in my case either &#8220;/en/&#8221; or &#8220;/de/&#8221;.</p>
<p>The following source code isn&#8217;t completely from me. I remember that I just searched the web for a good solution and changed it as I needed it, but that&#8217;s a longer time ago. Therefore no idea where parts or this code are from originally.</p>
<p>Anyway, here is the source code of the file <em>index.php</em> of my redirect theme just as I use it on this WordPress site right now:</p>
<pre class="brush: php; gutter: true">&lt;?php
/**
 * The main template file.
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Redirect
 */

/**
 * Detect browser language.
 *
 * @param array $allowed_languages An array of languages that are available on the site.
 * @param string $default_language Default language to use if none could be detected.
 * @param string $lang_variable Custom user language support. If not specified $_SERVER[&#039;HTTP_ACCEPT_LANGUAGE&#039;] is used.
 * @param string $strict_mode If true (default) the whole language code (&quot;en-us&quot;) is used and not only the left part (&quot;en&quot;).
 * @return string The detected browser language.
 */
function get_lang_from_browser($allowed_languages, $default_language, $lang_variable = NULL, $strict_mode = TRUE) {
    // Use $_SERVER[&#039;HTTP_ACCEPT_LANGUAGE&#039;] if no language variable is available
    if (NULL === $lang_variable)
        $lang_variable = $_SERVER[&#039;HTTP_ACCEPT_LANGUAGE&#039;];

    // Any info sent?
    if (empty($lang_variable))
        return $default_language;

    // Split the header
    $accepted_languages = preg_split(&#039;/,\s*/&#039;, $lang_variable);

    // Set default values
    $current_lang = $default_language;
    $current_q    = 0;
    // Now work through all included languages
    foreach ($accepted_languages as $accepted_language) {
        // Get all info about this language
        $res = preg_match(
            &#039;/^([a-z]{1,8}(?:-[a-z]{1,8})*)&#039;.
            &#039;(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i&#039;,
            $accepted_language,
            $matches
        );

        if (!$res)
            continue;

        // Get language code and split into parts immediately
        $lang_code = explode(&#039;-&#039;, $matches[1]);

        // Is there a quality set?
        if (isset($matches[2]))
            $lang_quality = (float)$matches[2];
        else
            $lang_quality = 1.0;

        // Until the language code is empty...
        while (count($lang_code)) {
            // Check if the language code is available
            if (in_array(strtolower(join(&#039;-&#039;, $lang_code)), $allowed_languages)) {
                // Check quality
                if ($lang_quality &gt; $current_q) {
                    $current_lang = strtolower(join(&#039;-&#039;, $lang_code));
                    $current_q = $lang_quality;
                    break;
                }
            }
            // If we&#039;re in strict mode we won&#039;t try to minimalize the language
            if ($strict_mode)
                break;

            // Cut the most right part of the language code
            array_pop($lang_code);
        }
    }

    return $current_lang;
}

$allowed_langs = array(&#039;en&#039;, &#039;de&#039;);
$lang = get_lang_from_browser($allowed_langs, &#039;en&#039;, NULL, FALSE);
header(&#039;Location: http://&#039; . $_SERVER[&#039;HTTP_HOST&#039;] . &quot;/$lang/&quot;);

exit();
?&gt;</pre>
<p>So just create a new theme folder and copy the PHP code above (change the allowed languages if needed, of course) into a file named <em>index.php</em>.</p>
<p>Then you just need to create an additional dummy file <em>style.css</em> with some info about the theme. Otherwise WordPress won&#8217;t recognize your theme:</p>
<pre class="brush: css; gutter: true">/*
Theme Name: Redirect
Theme URI: http://wordpress.org/extend/themes/redirect
Author: AB-WebLog.com
Author URI: http://www.ab-weblog.com
Description: Redirects
Version: 1.0
Tags: redirect
*/</pre>
<p>That&#8217;s it: after you have seleted this new theme for your main site &#8220;/&#8221;, every user will automatically be redirected to the correct language version based on the browser language settings.</p>
<p><em>Do you use the Multisite Language Switcher or your blog, too?</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ab-weblog.com/en/wordpress-multisite-redirect-users-based-on-their-browser-language/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Telephony Event Notifications of Polycom Phones Using PHP</title>
		<link>http://www.ab-weblog.com/en/telephony-event-notifications-of-polycom-phones-using-php/</link>
		<comments>http://www.ab-weblog.com/en/telephony-event-notifications-of-polycom-phones-using-php/#comments</comments>
		<pubDate>Thu, 01 Mar 2012 09:51:07 +0000</pubDate>
		<dc:creator>Andreas Breitschopp</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Polycom]]></category>
		<category><![CDATA[raw POST data]]></category>
		<category><![CDATA[Telephony]]></category>

		<guid isPermaLink="false">http://www.ab-weblog.com/en/?p=464</guid>
		<description><![CDATA[All current Polycom phones like the Polycom SoundPoint IP, the Polycom VVX 500/1500 or the Polycom SpectraLink series support event notifications. This is a great feature where the phone is sending a POST request to a previously defined URL for &#8230; <a href="http://www.ab-weblog.com/en/telephony-event-notifications-of-polycom-phones-using-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>All current Polycom phones like the Polycom SoundPoint IP, the Polycom VVX 500/1500 or the Polycom SpectraLink series support event notifications. This is a great feature where the phone is sending a POST request to a previously defined URL for various telephony events.</p>
<p>While developing a PHP server application that should handle some of these events, I came across the problem that there is no data in the PHP array <code>$_POST</code> although the script is called by the Polycom phone correctly.</p>
<p>After doing some investigation I found out that the data is not sent (for whatever reason) as &#8220;normal&#8221; POST key value pair, but just as raw POST data. Obviously PHP is therefore not able to add this raw POST data to the array <code>$_POST</code>.</p>
<p>Here is the way you can get the raw POST data anyway:</p>
<pre class="brush: php; gutter: true">// Make sure that there really is some raw POST data available
if ($_SERVER[&#039;REQUEST_METHOD&#039;] === &#039;POST&#039;) {
	// Now we can read the raw POST data from PHP standard input
	$rawPostData = trim(file_get_contents(&#039;php://input&#039;));
}</pre>
<p>As a result you have the XML data that was sent by the Polycom phone in the variable <code>$rawPostData</code>.</p>
<p><em>Did you also have problems receiving Polycom event data?</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ab-weblog.com/en/telephony-event-notifications-of-polycom-phones-using-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Script for Accessing VirusTotal API Version 2.0</title>
		<link>http://www.ab-weblog.com/en/php-script-for-accessing-virustotal-api-version-2-0/</link>
		<comments>http://www.ab-weblog.com/en/php-script-for-accessing-virustotal-api-version-2-0/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 10:53:28 +0000</pubDate>
		<dc:creator>Andreas Breitschopp</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[malware]]></category>
		<category><![CDATA[VirusTotal]]></category>

		<guid isPermaLink="false">http://www.ab-weblog.com/en/?p=443</guid>
		<description><![CDATA[Recently VirusTotal updated its API to version 2.0. As the version 1.0 is now deprecated, I have also updated my PHP script for accessing this API: Download PHP script for accessing VirusTotal API version 2.0 For a detailed description of this API &#8230; <a href="http://www.ab-weblog.com/en/php-script-for-accessing-virustotal-api-version-2-0/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently <a title="VirusTotal Service Website" href="http://www.virustotal.com" target="_blank">VirusTotal</a> updated its API to version 2.0. As the version 1.0 is now deprecated, I have also <a title="Using PHP to Access the Public VirusTotal API" href="http://www.ab-weblog.com/en/using-php-to-access-the-public-virustotal-api/">updated my PHP script for accessing this API</a>:</p>
<p style="text-align: center;"><strong><a title="VirusTotal API 2.0 PHP Implementation" href="http://www.ab-weblog.com/en/files/virustotal-api-2-0-php-implementation.zip">Download PHP script for accessing VirusTotal API version 2.0</a></strong></p>
<p style="text-align: left;">For a detailed description of this API implementation, please have a look on my <a title="Using PHP to Access the Public VirusTotal API" href="http://www.ab-weblog.com/en/using-php-to-access-the-public-virustotal-api/">post about VirusTotal API version 1.0</a>.</p>
<p style="text-align: left;"><em>Let me know if you have any questions or problems using this PHP API script.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ab-weblog.com/en/php-script-for-accessing-virustotal-api-version-2-0/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Using PHP to Access the Public VirusTotal API</title>
		<link>http://www.ab-weblog.com/en/using-php-to-access-the-public-virustotal-api/</link>
		<comments>http://www.ab-weblog.com/en/using-php-to-access-the-public-virustotal-api/#comments</comments>
		<pubDate>Mon, 26 Dec 2011 15:42:04 +0000</pubDate>
		<dc:creator>Andreas Breitschopp</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[malware]]></category>
		<category><![CDATA[VirusTotal]]></category>

		<guid isPermaLink="false">http://www.ab-weblog.com/en/?p=411</guid>
		<description><![CDATA[Updated script for VirusTotal API Version 2.0! As there is nowadays many spyware and malware out there, it is important to make sure that your own server stays clean. Therefore I often use the great VirusTotal service to check suspicious &#8230; <a href="http://www.ab-weblog.com/en/using-php-to-access-the-public-virustotal-api/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong><a title="PHP Script for Accessing VirusTotal API Version 2.0" href="http://www.ab-weblog.com/en/php-script-for-accessing-virustotal-api-version-2-0/">Updated script for VirusTotal API Version 2.0!</a></strong></p>
<p>As there is nowadays many spyware and malware out there, it is important to make sure that your own server stays clean.</p>
<p>Therefore I often use the great <a title="VirusTotal Service Website" href="http://www.virustotal.com" target="_blank">VirusTotal service</a> to check suspicious files.</p>
<p>For a certain project I wanted to automate this to be able to check some files and URLs in defined time intervals automatically. This can be easily done with the public VirusTotal API.</p>
<p>Unfortunately the link to the PHP implementation provided on the VirusTotal website is down. Therefore I decided to do my own PHP implementation of this API.</p>
<p>You can <a title="VirusTotal API PHP Implementation" href="http://www.ab-weblog.com/en/files/virustotal-api-php-implementation.zip">download a copy of my implementation</a>. The download contains also a small example script explaining how to use it. You&#8217;re free to use the implementation in your own projects. Of course, I&#8217;d be happy about a small backlink. <img src='http://www.ab-weblog.com/en/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>In my API implementation not only the default API functions are implemented that are well documented and therefore not explained here, but there are also several helper functions to make life easier which I will explain in the following:</p>
<ul>
<li><code class="brush: php; gutter: false">getScanID($result)</code>: returns the scan ID of a scan result that you can use to query a scan report later on.</li>
<li><code class="brush: php; gutter: false">displayResult($result)</code>: displays a scan or submission result in a user readable way.</li>
<li><code class="brush: php; gutter: false">getSubmissionDate($report)</code>: returns the submission date of a scan report.</li>
<li><code class="brush: php; gutter: false">getTotalNumberOfChecks($report)</code>: returns the total number of anti-virus checks of a scan report.</li>
<li><code class="brush: php; gutter: false">getNumberHits($report)</code>: returns the number of anti-virus hits (malware) of a scan report.</li>
<li><code class="brush: php; gutter: false">getReportPermalink($report, $withDate = TRUE)</code>: returns the permalink of the scan report. If <code class="brush: php; gutter: false">$withDate == TRUE</code>, permalink returns exactly the current scan report, otherwise it returns always the most recent scan report.</li>
</ul>
<p>These helper functions should make it much easier to work with the API results as you don&#8217;t need to care about the details of the returned JSON object anymore. <a title="VirusTotal API PHP Implementation" href="http://www.ab-weblog.com/en/files/virustotal-api-php-implementation.zip">Therefore here again the download of my free API implementation.</a></p>
<p><strong><a title="PHP Script for Accessing VirusTotal API Version 2.0" href="http://www.ab-weblog.com/en/php-script-for-accessing-virustotal-api-version-2-0/">Updated script for VirusTotal API Version 2.0!</a></strong></p>
<p><em>Did you use the VirusTotal service already yourself?</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ab-weblog.com/en/using-php-to-access-the-public-virustotal-api/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Flags Widget as Easy to Use WordPress Plug-In</title>
		<link>http://www.ab-weblog.com/en/flags-widget-as-easy-to-use-wordpress-plug-in/</link>
		<comments>http://www.ab-weblog.com/en/flags-widget-as-easy-to-use-wordpress-plug-in/#comments</comments>
		<pubDate>Sun, 30 Oct 2011 19:21:52 +0000</pubDate>
		<dc:creator>Andreas Breitschopp</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[country]]></category>
		<category><![CDATA[flag]]></category>
		<category><![CDATA[plug-in]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://www.ab-weblog.com/en/?p=347</guid>
		<description><![CDATA[Some minutes ago I’ve released my second WordPress plug-in: A simple plug-in that displays flag icons that link to other language versions of your blog. This plug-in combines my widget for displaying language selection flags in menu and footer with many &#8230; <a href="http://www.ab-weblog.com/en/flags-widget-as-easy-to-use-wordpress-plug-in/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Some minutes ago I’ve released my second WordPress plug-in: A simple plug-in that displays <a title="Flags Widget" href="http://www.ab-weblog.com/en/wordpress-plug-ins/flags-widget/">flag icons</a> that link to other language versions of your blog.</p>
<p>This plug-in combines my <a title="Widget for Displaying Language Selection Flags in Menu and Footer" href="http://www.ab-weblog.com/en/widget-for-displaying-language-selection-flags-in-menu-and-footer/">widget for displaying language selection flags in menu and footer</a> with many additional options and settings in one clean WordPress plug-in.</p>
<p>The <a title="Flags Widget" href="http://www.ab-weblog.com/en/wordpress-plug-ins/flags-widget/">installation and configuration</a> is very easy. Just have a look und let me know your thoughts!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ab-weblog.com/en/flags-widget-as-easy-to-use-wordpress-plug-in/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>Most Important Social Widgets as Easy to Use WordPress Plug-In</title>
		<link>http://www.ab-weblog.com/en/most-important-social-widgets-as-easy-to-use-wordpress-plug-in/</link>
		<comments>http://www.ab-weblog.com/en/most-important-social-widgets-as-easy-to-use-wordpress-plug-in/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 22:05:24 +0000</pubDate>
		<dc:creator>Andreas Breitschopp</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[plug-in]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://www.ab-weblog.com/en/?p=240</guid>
		<description><![CDATA[Some minutes ago I&#8217;ve released my first WordPress plug-in: it displays the most important social widgets of Facebook, Twitter and Google+ below your posts. Now the question is: Why yet another social widgets plug-in as there are already a lot &#8230; <a href="http://www.ab-weblog.com/en/most-important-social-widgets-as-easy-to-use-wordpress-plug-in/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Some minutes ago I&#8217;ve released my first WordPress plug-in: it displays the most important <a title="Social Widgets" href="http://www.ab-weblog.com/en/wordpress-plug-ins/social-widgets/">social widgets of Facebook, Twitter and Google+ </a>below your posts.</p>
<p><em>Now the question is:</em><br />
Why yet another social widgets plug-in as there are already a lot of them?</p>
<p>The answer is that I&#8217;ve searched for a simple and easy to user plug-in and all plug-ins I&#8217;ve found were way to complicated: I did not want to have countless of social networks supported with hundreds of options &#8211; just a simple plug-in covering the most important social widgets without needing to configure anything!</p>
<p><em>And that&#8217;s my new plug-in:</em><br />
<a title="Social Widgets" href="http://www.ab-weblog.com/en/wordpress-plug-ins/social-widgets/">Install it</a>, activate it and the social widgets are displayed below your posts immediately &#8211; without doing any configuration.</p>
<p><em>What social widgets plug-in do you use?</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ab-weblog.com/en/most-important-social-widgets-as-easy-to-use-wordpress-plug-in/feed/</wfw:commentRss>
		<slash:comments>105</slash:comments>
		</item>
		<item>
		<title>Create New Posts With Publishing Date in WordPress Using XML-RPC and PHP</title>
		<link>http://www.ab-weblog.com/en/create-new-posts-with-publishing-date-in-wordpress-using-xml-rpc-and-php/</link>
		<comments>http://www.ab-weblog.com/en/create-new-posts-with-publishing-date-in-wordpress-using-xml-rpc-and-php/#comments</comments>
		<pubDate>Sun, 04 Sep 2011 17:51:00 +0000</pubDate>
		<dc:creator>Andreas Breitschopp</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[ISO 8601]]></category>
		<category><![CDATA[XML-RPC]]></category>

		<guid isPermaLink="false">http://www.ab-weblog.com/en/?p=215</guid>
		<description><![CDATA[To be able to add new posts to a WordPress blog I wanted to use XML-RPC interface with PHP. First of all you need to enable the checkbox &#8220;Enable the WordPress, Movable Type, MetaWeblog and Blogger XML-RPC publishing protocols.&#8221; in &#8230; <a href="http://www.ab-weblog.com/en/create-new-posts-with-publishing-date-in-wordpress-using-xml-rpc-and-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>To be able to add new posts to a WordPress blog I wanted to use XML-RPC interface with PHP.</p>
<p>First of all you need to enable the checkbox &#8220;Enable the WordPress, Movable Type, MetaWeblog and Blogger XML-RPC publishing protocols.&#8221; in the menu &#8220;Settings&#8221;/&#8221;Writing&#8221;.</p>
<p>Now I searched on the web for a ready-to-use solution as I was probably not the first one who wanted to accomplish that. And as expected there were also many PHP scripts doing exactly that, but with one problem:<br />
I wanted to set also the publishing date manually with the PHP request and most scripts I&#8217;ve found did not even try to do that at all.</p>
<p>Few scripts in fact did try to set the publishing date, but the result was an error message similar to:<br />
<strong>Fatal error</strong>: Call to a member function getIso() on a non-object in <strong>/var/www/wp-includes/class-wp-xmlrpc-server.php</strong> on line <strong>2373</strong></p>
<p>After reading some documents regarding this strange ISO 8601 date format that is needed there, I found a solution myself:</p>
<pre class="brush: php; gutter: true">/**
 * Performs a XML-RPC to a WordPress blog and adds a new post.
 *
 * @param string $title Title of the new post.
 * @param string $body Body text of the new post.
 * @param string $rpcurl RPC-URL of the blog (normally xmlrpc.php in the root directory).
 * @param string $username User name used to add the new post.
 * @param string $password Password used to add the new post.
 * @param string $categories Comma separated list of categories (make sure they already exist in your blog).
 * @param string $keywords Comma separated list of keywords/tags (in contrast to the categories they don't need to exist already).
 * @param string $pubdate Publishing date in ISO 8601 (with date('c') in PHP; current time is used if empty).
 * @param string $draftonly True to save as draft only, False to publish directly (default).
 * @return string The result of the XML-RPC.
 */
function wpPostXMLRPC($title, $body, $rpcurl, $username, $password, $categories, $keywords = '', $pubdate = '', $draftonly = false) {
	$content = array(
		'title' =&gt; $title,
		'description' =&gt; $body,
		'mt_allow_comments' =&gt; 1,
		'mt_allow_pings' =&gt; 1,
		'post_type' =&gt; 'post',
		'date_created_gmt' =&gt; '%pubdate%', // Just as place holder here.
		'mt_keywords' =&gt; $keywords,
		'categories' =&gt; array($categories)
	);
	$params = array(0, $username, $password, $content, !$draftonly);

	$request = xmlrpc_encode_request('metaWeblog.newPost', $params);
	// Now we need to set the real publishing date:
	$request = str_replace('&lt;string&gt;%pubdate%&lt;/string&gt;',
			       '&lt;dateTime.iso8601&gt;' . $pubdate . '&lt;/dateTime.iso8601&gt;',
			       $request);

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
	curl_setopt($ch, CURLOPT_URL, $rpcurl);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_TIMEOUT, 1);
	$results = curl_exec($ch);
	curl_close($ch);
	return $results;
}</pre>
<p>As you can see I inserted the data structure needed for the correct ISO 8601 date format myself directly into the XML request. This is probably not the most elegant way, but it works perfectly. <img src='http://www.ab-weblog.com/en/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p><em>Did you come across the same issue already yourself?</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ab-weblog.com/en/create-new-posts-with-publishing-date-in-wordpress-using-xml-rpc-and-php/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Widget for Displaying Language Selection Flags in Menu and Footer</title>
		<link>http://www.ab-weblog.com/en/widget-for-displaying-language-selection-flags-in-menu-and-footer/</link>
		<comments>http://www.ab-weblog.com/en/widget-for-displaying-language-selection-flags-in-menu-and-footer/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 18:37:27 +0000</pubDate>
		<dc:creator>Andreas Breitschopp</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[multilingual]]></category>
		<category><![CDATA[multisite]]></category>
		<category><![CDATA[plug-in]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://www.ab-weblog.com/en/?p=32</guid>
		<description><![CDATA[After I decided to use the WordPress Multisite feature for my multilingual blog (see this post), I wanted to display language selection flags inside the menu and in the footer. It turned out that especially the integration of images on &#8230; <a href="http://www.ab-weblog.com/en/widget-for-displaying-language-selection-flags-in-menu-and-footer/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After I decided to use the WordPress Multisite feature for my multilingual blog (<a title="Multilingual Blog in WordPress: qTranslate, WPML or Multisite Feature" href="http://www.ab-weblog.com/en/multilingual-blog-in-wordpress-qtranslate-wpml-or-multisite-feature/">see this post</a>), I wanted to display language selection flags inside the menu and in the footer.</p>
<p>It turned out that especially the integration of images on the right side of the (by default black) menu area was not very easy in the &#8220;Twenty Eleven&#8221; theme. Therefore I decided to just create a simple widget that displays the flags in a DIV which is placed above all other content and this way can easily be positioned with relative coordinates directly from within the admin widget interface.</p>
<p>Therefore you can define these settings in the admin area:</p>
<p><a href="http://www.ab-weblog.com/en/files/flags_widget_admin.png"><img class="aligncenter size-full wp-image-33" title="Flags Widget (Admin Interface)" src="http://www.ab-weblog.com/en/files/flags_widget_admin.png" alt="Flags Widget (Admin Interface)" width="262" height="252" /></a></p>
<ul>
<li>Flag position offset (left): the relative offset of the X coordinate of the DIV.</li>
<li>Flag position offset (top): the relative offset of the Y coordinate of the DIV.</li>
<li>Flag icon URL (en): the flag icon URL for the English flag (first uploaded, of course).</li>
<li>Flag icon URL (de): the flag icon URL for the German flag (first uploaded, of course).</li>
</ul>
<p>Obviously this can be easily extended with more or other languages if needed.</p>
<p>And here is the widget source code:</p>
<pre class="brush: php; gutter: true">&lt;?php
/**
 * Flags_Widget Class
 */
class Flags_Widget extends WP_Widget {
	/** constructor */
	function Flags_Widget() {
		parent::WP_Widget(false, $name = 'Flags_Widget');
	}

	/** @see WP_Widget::widget */
	function widget($args, $instance) {
		extract($args);
		?&gt;
			&lt;div style="position: relative;"&gt;
				&lt;div style="left: &lt;?php echo $instance['flags_position_left']; ?&gt;px; top: &lt;?php echo $instance['flags_position_top']; ?&gt;px; position: absolute; z-index: 10000 !important;"&gt;
					&lt;?php echo '&lt;a href="/en/"&gt;&lt;img src="' . $instance['flag_en'] . '" width="20" height="16" title="English" alt="English" /&gt;'; ?&gt;&lt;/a&gt;  
					&lt;?php echo '&lt;a href="/de/"&gt;&lt;img src="' . $instance['flag_de'] . '" width="20" height="16" title="Deutsch" alt="Deutsch" /&gt;&lt;/a&gt;'; ?&gt;
				&lt;/div&gt;
			&lt;/div&gt;
		&lt;?php
	}

	/** @see WP_Widget::update */
	function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance['flags_position_left'] = strip_tags($new_instance['flags_position_left']);
		if (!is_numeric($instance['flags_position_left'])) $instance['flags_position_left'] = '0';
		$instance['flags_position_top'] = strip_tags($new_instance['flags_position_top']);
		if (!is_numeric($instance['flags_position_top'])) $instance['flags_position_top'] = '0';
		$instance['flag_en'] = strip_tags($new_instance['flag_en']);
		$instance['flag_de'] = strip_tags($new_instance['flag_de']);
		return $instance;
	}

	/** @see WP_Widget::form */
	function form($instance) {
		$flags_position_left = esc_attr($instance['flags_position_left']);
		if ($flags_position_left == '') $flags_position_left = '0';
		$flags_position_top = esc_attr($instance['flags_position_top']);
		if ($flags_position_top == '') $flags_position_top = '0';
		$flag_en = esc_attr($instance['flag_en']);
		$flag_de = esc_attr($instance['flag_de']);
		?&gt;
			&lt;p&gt;
				&lt;label for="&lt;?php echo $this-&gt;get_field_id('flags_position_left'); ?&gt;"&gt;&lt;?php _e('Flag position offset (left):'); ?&gt;&lt;/label&gt;
				&lt;input class="widefat" id="&lt;?php echo $this-&gt;get_field_id('flags_position_left'); ?&gt;"
					name="&lt;?php echo $this-&gt;get_field_name('flags_position_left'); ?&gt;" type="text" value="&lt;?php echo $flags_position_left; ?&gt;" /&gt;
				&lt;label for="&lt;?php echo $this-&gt;get_field_id('flags_position_top'); ?&gt;"&gt;&lt;?php _e('Flag position offset (top):'); ?&gt;&lt;/label&gt;
				&lt;input class="widefat" id="&lt;?php echo $this-&gt;get_field_id('flags_position_top'); ?&gt;"
					name="&lt;?php echo $this-&gt;get_field_name('flags_position_top'); ?&gt;" type="text" value="&lt;?php echo $flags_position_top; ?&gt;" /&gt;
				&lt;label for="&lt;?php echo $this-&gt;get_field_id('flag_en'); ?&gt;"&gt;&lt;?php _e('Flag icon URL (en):'); ?&gt;&lt;/label&gt;
				&lt;input class="widefat" id="&lt;?php echo $this-&gt;get_field_id('flag_en'); ?&gt;"
					name="&lt;?php echo $this-&gt;get_field_name('flag_en'); ?&gt;" type="text" value="&lt;?php echo $flag_en; ?&gt;" /&gt;
				&lt;label for="&lt;?php echo $this-&gt;get_field_id('flag_de'); ?&gt;"&gt;&lt;?php _e('Flag icon URL (de):'); ?&gt;&lt;/label&gt;
				&lt;input class="widefat" id="&lt;?php echo $this-&gt;get_field_id('flag_de'); ?&gt;"
					name="&lt;?php echo $this-&gt;get_field_name('flag_de'); ?&gt;" type="text" value="&lt;?php echo $flag_de; ?&gt;" /&gt;
			&lt;/p&gt;
		&lt;?php
	}
} // class Flags_Widget
add_action('widgets_init', create_function('', 'return register_widget("Flags_Widget");'));
?&gt;</pre>
<p>I wanted to keep it simple and therefore all together in one file. Otherwise you should at least put the CSS styles inside an external style sheet file, of course.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ab-weblog.com/en/widget-for-displaying-language-selection-flags-in-menu-and-footer/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Display Only Excerpts Instead of Full Posts</title>
		<link>http://www.ab-weblog.com/en/display-only-excerpts-instead-of-full-posts/</link>
		<comments>http://www.ab-weblog.com/en/display-only-excerpts-instead-of-full-posts/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 14:05:49 +0000</pubDate>
		<dc:creator>Andreas Breitschopp</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[theme]]></category>

		<guid isPermaLink="false">http://www.ab-weblog.com/en/?p=23</guid>
		<description><![CDATA[By default in the theme &#8220;Twenty Eleven&#8221; of WordPress everywhere (except for search results) full posts are displayed. But I don&#8217;t like that, because if I click on a category or tag, I just want to get an overview what &#8230; <a href="http://www.ab-weblog.com/en/display-only-excerpts-instead-of-full-posts/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>By default in the theme &#8220;Twenty Eleven&#8221; of WordPress everywhere (except for search results) full posts are displayed. But I don&#8217;t like that, because if I click on a category or tag, I just want to get an overview what posts are assigned to it. If I want to read one completely, I can still click on it.</p>
<p>Therefore I wanted to display only excerpts of posts for following pages:</p>
<ul>
<li>Search results (which is the case by default already)</li>
<li>Homepage of the blog</li>
<li>Category archive pages</li>
<li>Tag archive pages</li>
<li>Date-based archive pages (I don&#8217;t use them at all right now)</li>
</ul>
<p>To accomplish that, you just have to replace the line in the &#8220;content.php&#8221; theme file</p>
<pre class="brush: php; gutter: false">&lt;?php if ( is_search() ) : // Only display Excerpts for Search ?&gt;</pre>
<p>with this one:</p>
<pre class="brush: php; gutter: false">&lt;?php if ( is_home() || is_tag() || is_category() || is_date() || is_search() ) : ?&gt;</pre>
<p>That&#8217;s it. Now at least I think it looks better for the user and I&#8217;m sure also search engines don&#8217;t mind that (keyword: &#8220;duplicate content&#8221;). <img src='http://www.ab-weblog.com/en/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.ab-weblog.com/en/display-only-excerpts-instead-of-full-posts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using the Shopping.com API in PHP</title>
		<link>http://www.ab-weblog.com/en/using-the-shopping-com-api-in-php/</link>
		<comments>http://www.ab-weblog.com/en/using-the-shopping-com-api-in-php/#comments</comments>
		<pubDate>Sun, 15 Aug 2010 15:19:48 +0000</pubDate>
		<dc:creator>Andreas Breitschopp</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Shopping.com]]></category>

		<guid isPermaLink="false">http://www.ab-weblog.com/en/?p=173</guid>
		<description><![CDATA[After an example of the eBay Finding API and the Amazon Product Advertising API in previous posts, I finally want to show an example of the Shopping.com API. First of all you need to register for a free Shopping.com developer &#8230; <a href="http://www.ab-weblog.com/en/using-the-shopping-com-api-in-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After an example of the <a title="Using the eBay Finding API in PHP" href="http://www.ab-weblog.com/en/using-the-ebay-finding-api-in-php/">eBay Finding API</a> and the <a title="Using the Amazon Product Advertising API in PHP" href="http://www.ab-weblog.com/en/using-the-amazon-product-advertising-api-in-php/">Amazon Product Advertising API</a> in previous posts, I finally want to show an example of the Shopping.com API.</p>
<p>First of all you need to register for a free <a title="Shopping.com Developer Website" href="http://developer.shopping.com" target="_blank">Shopping.com developer account</a>.</p>
<p>Then you can start building the API request URL:</p>
<pre class="brush: text; gutter: true">http://publisher.api.shopping.com/publisher/3.0/rest/GeneralSearch?
	apiKey=%apikey%&amp;
	trackingId=%trackingid%&amp;
	subTrackingId=%subTrackingId%&amp;
	categoryId=%categoryId%&amp;
	keyword=%keyword%&amp;
	pageNumber=%pageNumber%&amp;
	numItems=%numItems%&amp;
	hybridSortType=%hybridSortType%
	hybridSortOrder=%hybridSortOrder%</pre>
<p>Now let&#8217;s see what the individual parameters mean:</p>
<ul>
<li><em>GeneralSearch:</em> we need the operation <em><a title="More Info About the Operation GeneralSearch" href="http://developer.shopping.com/docs/read/API_Use_Cases#Searching" target="_blank">GeneralSearch</a></em> for our keyword-based search.</li>
<li><em>apiKey:</em> you get this API key in your Shopping.com developer account.</li>
<li><em>trackingId:</em> you need to request a tracking ID from Shopping.com to earn some money with your traffic.</li>
<li><em>subTrackingId:</em> choose any additional code here you want to use as optional tracking (e. g. for special campaigns).</li>
<li><em>categoryId:</em> the category you want to search in (leave empty to search in all categories).</li>
<li><em>keyword:</em> your search keywords. Make sure you use <em>utf8_decode</em> if the keywords are in UTF-8.</li>
<li><em>pageNumber:</em> for the first request you set this to <em>1</em> and increase it in previous requests if you need more items.</li>
<li><em>numItems:</em> here you can choose how many items (maximal 100) are returned per request.</li>
<li><em>hybridSortType:</em> choose if you want the result to be sorted by <em>relevance</em> or <em>price</em>.</li>
<li><em>hybridSortOrder:</em> choose if you want the result to be sorted <em>ascending</em> or <em>descending</em>.</li>
</ul>
<p>That&#8217;s all: we just need to pass this URL again to the small function we used already in the <a title="Using the eBay Finding API in PHP" href="http://www.ab-weblog.com/en/using-the-ebay-finding-api-in-php/">eBay Finding API</a> and the <a title="Using the Amazon Product Advertising API in PHP" href="http://www.ab-weblog.com/en/using-the-amazon-product-advertising-api-in-php/">Amazon Product Advertising API</a> examples and receive the XML response data:</p>
<pre class="brush: php; gutter: true">/**
 * Returns the SimpleXML object.
 *
 * @param string $url The URL to receive the XML document.
 * @return string The SimpleXML object.
 *
 */
function getXml($url) {
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_HEADER, false);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_TIMEOUT, 3);
	$result = curl_exec($ch);
	curl_close($ch);

	return simplexml_load_string($result);
}</pre>
<p>As you can see the Shopping.com API is very easy to handle as it is also the smallest of these three APIs.</p>
<p><em>Did you use the Shopping.com API yourself already?<br />
Do you know other interesting online shopping APIs?</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ab-weblog.com/en/using-the-shopping-com-api-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->