Monday, January 11, 2010

Tweet with FileMaker (simple method, Win+Mac, No Curl)

In the following article, I would like to demonstrate how you can update your twitter status with filemaker using a very simple method.

Recently I see a solution floating around which uses CURL to do this, but it's Mac only, and why use curl, if we don't need it?

We'll just use a simple web viewer to do this.

First we need to understand how we can update our status using twitter API. You can check this here.

If we have this, we just need to create a web viewer, with a post html form, and a so called "self-posting" javascript code in it.

This is it:

"data:text/html," &
"<html>
<head>
<script>
function PostMe() {document.getElementById(\"myform\").submit();}
</script>
</head>
<body onload=\"PostMe()\">
<form id=\"myform\" method=\"post\" action=\"http://" & FmPostTwit::UserName_Global & ":" & FmPostTwit::PassWord_Global & "@twitter.com/statuses/update.xml\" enctype=\"application/x-www-form-urlencoded;charset=utf-8\" accept-charset=\"UTF-8\">
<input type=\"hidden\" name=\"status\" value=\"" & FmPostTwit::Status_Global & "\">
</form>
</body>
</html>"



Let's take a look at it.

The "data:text/html," part is to let the web viewer have inner html content(the form).

The next part is the javascript code, which will post the form when it loads.

The last part is the html form, with the needed input (status- hidden).


This will be put into a web viewer(object name vw) by the Set Web Viewer Script step- Go To URL.


So basically the one line code is:


Set Web Viewer[Object Name:vw; URL: here comes the html code from above]


That's all.


I attached a sample file, which you can download here.


Please check it, and use this technique it if you like it.


Please visit our site, http://crm.fm which has our main FileMaker product, and support us by buying it. Thanks!

The material on this document is offered as is. There is no representation or warranty, expressed or implied, nor does any other contributor to this post. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.