<?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>Joe's Amazing Technicolor Weblog &#187; FileMaker</title>
	<atom:link href="http://slagwerks.com/blog/index.php/tag/filemaker/feed/" rel="self" type="application/rss+xml" />
	<link>http://slagwerks.com/blog</link>
	<description></description>
	<lastBuildDate>Fri, 23 Jul 2010 22:31:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Considering how to reliably jam stuff into FileMaker from the web</title>
		<link>http://slagwerks.com/blog/index.php/2009/10/23/considering-how-to-reliably-jam-stuff-into-filemaker-from-the-web/</link>
		<comments>http://slagwerks.com/blog/index.php/2009/10/23/considering-how-to-reliably-jam-stuff-into-filemaker-from-the-web/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 16:43:52 +0000</pubDate>
		<dc:creator>joe</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Tech Stuff]]></category>
		<category><![CDATA[FileMaker]]></category>

		<guid isPermaLink="false">http://slagwerks.com/blog/?p=322</guid>
		<description><![CDATA[I&#8217;m sure I&#8217;m not the only person with this&#160;situation: FileMaker database sitting behind a firewall (though similar issues would pertain for other internal databases /&#160;services) Website hosted elsewhere (i.e. other side of&#160;firewall) Need to get data from #2 to #1 reliably and&#160;securely Up until today, I&#8217;ve only had one instance of #2 in this situation. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sure I&#8217;m not the only person with this&nbsp;situation:</p>
<ol>
<li>FileMaker database sitting behind a firewall (though similar issues would pertain for other internal databases /&nbsp;services)</li>
<li>Website hosted elsewhere (i.e. other side of&nbsp;firewall)</li>
<li>Need to get data from #2 to #1 reliably and&nbsp;securely</li>
</ol>
<p>Up until today, I&#8217;ve only had one instance of #2 in this situation. I dealt with it by storing data collected on the website (which happened to be written in Rails) in a database on the web server, and then running a periodic <span class="caps">PHP</span> script on the FileMaker server that connects to the Rails app via <a href="http://github.com/lux/phpactiveresource">phpactiveresource</a>, pulls in pending data, and inserts it into FileMaker via its <span class="caps">PHP</span>&nbsp;api.</p>
<p>That instance was such a roaring success that the requests have been pouring in for more of the same. Some of the new requests will be handled by a site running <span class="caps">PHP</span>, so I&#8217;ve got a bit of rewiring to do&thinsp;&#8212;&thinsp;I can&#8217;t see any sense in the getting the data from the <span class="caps">PHP</span> app into something the Active Resource client can talk&nbsp;to.</p>
<p>Stepping back and looking at the bigger picture, issues here&nbsp;include:</p>
<ul>
<li>the connection from the website to the FileMaker server could be down, so data collected by the website needs to be stored until it can be confirmed to have made it to&nbsp;FileMaker.</li>
<li>it would be nice for this to happen in a timely&nbsp;fashion</li>
<li>multiple technologies on the web side (<span class="caps">PHP</span> <span class="amp">&amp;</span> ruby) are going to be collecting data to be submitted to FileMaker, so it&#8217;d be nice if the transfer machinery can be agnostic and just accept <span class="caps">JSON</span> or <span class="caps">XML</span> or&nbsp;something.</li>
</ul>
<p>Sounds like a problem for a queue system, huh? So my current plan is to run a <a href="http://kr.github.com/beanstalkd/">beanstalkd</a> instance on the webserver, deposit <span class="caps">JSON</span>-endocded data into it from the web sites, and run workers that write to FileMaker using the <a href="http://github.com/lardawge/rfm">Ruby <span class="caps">FM</span> <span class="caps">API</span></a>. I have no experience with beanstalkd, but a bit of googling suggests that it&#8217;s at a nice point in simplicity to configure <span class="amp">&amp;</span> run, maturity, light weight, and easy access from <span class="caps">PHP</span> <span class="amp">&amp;</span>&nbsp;Ruby.</p>
<p>A further benefit of working in beanstalkd is that, based on a quick perusal of the <a href="http://async-observer.rubyforge.org/">recommended Rails integration</a>, it should be really easy to break Observers out to async code, thus making my rails apps&nbsp;snappier.</p>
<p>Any advice to the contrary is of course welcome. I&#8217;ll try to remember to update y&#8217;all on how this turns&nbsp;out.</p>
]]></content:encoded>
			<wfw:commentRss>http://slagwerks.com/blog/index.php/2009/10/23/considering-how-to-reliably-jam-stuff-into-filemaker-from-the-web/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FileMaker error 100</title>
		<link>http://slagwerks.com/blog/index.php/2008/11/21/filemaker-error-100/</link>
		<comments>http://slagwerks.com/blog/index.php/2008/11/21/filemaker-error-100/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 11:29:54 +0000</pubDate>
		<dc:creator>joe</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Tech Stuff]]></category>
		<category><![CDATA[FileMaker]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://slagwerks.com/blog/?p=208</guid>
		<description><![CDATA[or, Why To Use Dedicated Layouts When Connecting To FileMaker Via&#160;PHP I&#8217;d read that it&#8217;s a good practice to always use a dedicated layout for any PHP scripts you have that are talking to a FileMaker database. While I&#8217;d seen reasons of efficiency and reliability, today I learned another reason that&#8217;s true: it can eliminate [...]]]></description>
			<content:encoded><![CDATA[<p><em>or, Why To Use Dedicated Layouts When Connecting To FileMaker Via&nbsp;<span class="caps">PHP</span></em></p>
<p>I&#8217;d read that it&#8217;s a good practice to always use a dedicated layout for any <span class="caps">PHP</span> scripts you have that are talking to a FileMaker database. While I&#8217;d seen reasons of efficiency and reliability, today I learned another reason that&#8217;s true: it can eliminate otherwise hard-to-debug&nbsp;problems.</p>
<p>At first when working on my current FileMaker &lt;-&gt; <span class="caps">PHP</span> project, I was attempting to reuse an existing layout that had all the info I needed. While my permissions seemed to be fine for the data file and layout I was attempting to access, actually running the script kept resulting in &#8220;Error 100: File is missing&#8221; coming back at me as soon as I added any criteria to my search. FileMaker doesn&#8217;t bother putting anything useful in its server logs, either, so it wouldn&#8217;t have been much fun picking through the layout <span class="amp">&amp;</span> figuring what linkage(s) were to&nbsp;blame.</p>
<p>However, by simply creating a dedicated layout, everything started working as planned. A practice I&#8217;ll be following in the&nbsp;future.</p>
]]></content:encoded>
			<wfw:commentRss>http://slagwerks.com/blog/index.php/2008/11/21/filemaker-error-100/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sending email from FileMaker via PHP, revisited</title>
		<link>http://slagwerks.com/blog/index.php/2008/10/22/sending-email-from-filemaker-via-php-revisited/</link>
		<comments>http://slagwerks.com/blog/index.php/2008/10/22/sending-email-from-filemaker-via-php-revisited/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 15:57:01 +0000</pubDate>
		<dc:creator>joe</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Tech Stuff]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[FileMaker]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://slagwerks.com/blog/?p=118</guid>
		<description><![CDATA[We last looked at this a few months ago, but have been revisiting it to come up with something a little more robust.&#160;Notes: there&#8217;s a good overview of using PHP with FM at the sixfriedrice&#160;blog. the API for FileMaker&#8217;s PHP interface is available at&#160;http://YOURSERVER.URL:16000/docs/PHP%20API%20Documentation/index.html I&#8217;d missed this last time around, but accounts &#38; permissions are [...]]]></description>
			<content:encoded><![CDATA[<p>We last looked at this <a href="http://slagwerks.com/blog/index.php/2008/06/12/sending-server-side-emails-from-filemaker-via-php/  ">a few months ago</a>, but have been revisiting it to come up with something a little more robust.&nbsp;Notes:</p>
<ul>
<li>there&#8217;s a good overview of using <span class="caps">PHP</span> with <span class="caps">FM</span> <a href="http://sixfriedrice.com/wp/up-to-speed-with-the-filemaker-php-api/">at the sixfriedrice&nbsp;blog</a>.</li>
<li>the <span class="caps">API</span> for FileMaker&#8217;s <span class="caps">PHP</span> interface is available at&nbsp;http://<span class="caps">YOURSERVER</span>.<span class="caps">URL</span>:16000/docs/<span class="caps">PHP</span>%<span class="caps">20API</span>%20Documentation/index.html</li>
<li>I&#8217;d missed this last time around, but accounts <span class="amp">&amp;</span> permissions are a little funky. <em>fmphp</em> needs to be added to the Extended Privileges of the database you&#8217;re trying to get to, and must have the same privilege set as the account you&#8217;re connecting&nbsp;as.</li>
<li>The solution we settled on is a <span class="caps">CLI</span> <span class="caps">PHP</span> script running hourly, checking for mail to send. Launchd would be the logical way to do the scheduling, but always drives me nuts. Fortunately the server in question has cron set up (so much&nbsp;simpler!)</li>
</ul>
<p>The code we&#8217;re more or less&nbsp;using:</p>
<pre><code>
#!/usr/bin/php
&lt;?php
set_include_path(get_include_path() . PATH_SEPARATOR .
  '/Library/FileMaker Server/Web Publishing/publishing-engine/php/lib/php/');
require_once('FileMaker.php');

echo "PHP email-sending-script, running at " .
  date('m/d/Y H:i') . "\n";
$layout = 'Outgoing_Email';
$fm = new FileMaker('Layout Name');
$fm-&gt;setProperty('username', 'your filemaker username');
$fm-&gt;setProperty('password', 'your filemaker password');

$findCmd =&amp; $fm-&gt;newFindCommand($layout);
$findCmd-&gt;addFindCriterion('Sent_Flag', '&lt; 1');
$result = $findCmd-&gt;execute();
if (FileMaker::isError($result)) {
  if ($result-&gt;code == 401) {
    exit("No emails to send.\n");
  } else {
    exit("trouble: " . $result-&gt;message . "(" . $result-&gt;code . ")");
  }
}

$records = $result-&gt;getRecords();
foreach($records as $record) {
  echo "To: " . $record-&gt;getField('Recipient') . "\n";
  echo "Subject: " . $record-&gt;getField('Subject') . "\n";
  $headers = array(
    "From: filemaker@example.com",
    "MIME-Version: 1.0",
    "Content-type: text/html"
    );

  /*
   FM helpfully encodes &lt; and &gt;...
   */
  $body = preg_replace('/&amp;lt;/', '&lt; ', $record-&gt;getField('Body'));
  $body = preg_replace('/&amp;gt;/', '&gt;', $body);
  $rc = mail($record-&gt;getField('Recipient'),
       $record-&gt;getField('Subject'),
       $body,
       implode("\r\n", $headers)
      );
  if ($rc) {
    $update = $fm-&gt;newEditCommand($layout, $record-&gt;getRecordId());
    $update-&gt;setField('Sent_Date', date('m/d/Y'));
    $update-&gt;setField('Sent_Time', date('H:i'));
    $update-&gt;setField('Sent_Flag', '1');
    $result = $update-&gt;execute();
    if (FileMaker::isError($result)) {
      exit("trouble updating the database after sending email: " .
        $result-&gt;message . "(" . $result-&gt;code . ")");
    }
    echo "Mailed!\n";
  } else {
    exit("Mail didn't work.\n");
  }
}

</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://slagwerks.com/blog/index.php/2008/10/22/sending-email-from-filemaker-via-php-revisited/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sending server-side emails from FileMaker via PHP</title>
		<link>http://slagwerks.com/blog/index.php/2008/06/12/sending-server-side-emails-from-filemaker-via-php/</link>
		<comments>http://slagwerks.com/blog/index.php/2008/06/12/sending-server-side-emails-from-filemaker-via-php/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 23:15:54 +0000</pubDate>
		<dc:creator>joe</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[FileMaker]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://slagwerks.com/blog/?p=57</guid>
		<description><![CDATA[Some context&#8201;&#8212;&#8201;my new gig features a big &#8216;ol FileMaker installation, which has a number of automated maintenance routines. Some of those routines send emails, through a convoluted process involving FileMaker calling a GUI MUA (e.g. Mail.app). There are a number of practical problems with this, such as the requirement of another computer running, always logged [...]]]></description>
			<content:encoded><![CDATA[<p>Some context&thinsp;&#8212;&thinsp;my new gig features a big &#8216;ol <a href="http://en.wikipedia.org/wiki/FileMaker">FileMaker</a> installation, which has a number of automated maintenance routines. Some of those routines send emails, through a convoluted process involving FileMaker calling a <span class="caps">GUI</span> <span class="caps">MUA</span> (e.g. Mail.app). There are a number of practical problems with this, such as the requirement of another computer running, always logged into an account capable of sending the&nbsp;emails.</p>
<p>We&#8217;d done a bit of research about strictly server-side alternatives, and found surprisingly little. The best resource was <a href="http://www.grahamsprague.com/server_side_email/server_side_email.html">Graham Sprague&#8217;s page about sending emails via FileMaker&#8217;s <span class="caps">XSLT</span> Web Publishing tool</a>. We gave that approach a try, but didn&#8217;t get any results, or anything useful from FileMaker&#8217;s logs to explain why things weren&#8217;t working. I&#8217;m not sure what FileMaker version Graham&#8217;s example was written for, perhaps something&#8217;s changed with version&nbsp;9?</p>
<p>Rather than dive into FileMaker&#8217;s proprietary <span class="caps">XSLT</span> system to debug things, it occurred to me that this might be a job for FileMaker&#8217;s <span class="caps">PHP</span> <span class="caps">API</span>. Sure enough, after about 15 minutes of consulting the <span class="caps">API</span> Doc, we were sending emails based on the contents of a FileMaker&nbsp;record. </p>
<p>We&#8217;re still working on ironing out the details, but here&#8217;s the rough proof of concept <span class="caps">PHP</span> file. It works with the example email database from Graham&#8217;s <span class="caps">XSLT</span> sample, with the php permission added to the database. Plenty of missing features such as cc <span class="amp">&amp;</span> bcc fields, actually checking for the &#8216;send&#8217; flag, checking for errors, any kind of authorization or authentication, etc. In other words, you probably don&#8217;t want to be running this on a publicly accessible webserver, but at least it presents the basic idea in a simple&nbsp;form.</p>
<pre><code>
&lt;?php
require_once('FileMaker.php');
$fm = new FileMaker();
$fm->setProperty('username', 'send_email');
$fm->setProperty('password', 'whatever_the_password_is');
$fm->setProperty('database', 'Email');

$findCmd =&#038; $fm->newFindAllCommand('Utility_Email');
$result = $findCmd->execute();
$records = $result->getRecords();
foreach($records as $record) {
  $headers = array("From: " . $record->getField('from'));

  mail($record->getField('to'),
       $record->getField('subject'),
       $record->getField('message'),
       implode("\r\n", $headers)
      );
}
echo "Emails sent";
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://slagwerks.com/blog/index.php/2008/06/12/sending-server-side-emails-from-filemaker-via-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
