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.

Sunday, January 10, 2010

Importing Twitter Friend Timeline into FileMaker

In the following article, I would like to demonstrate how you can use the twitter api to import your friends' timeline into FileMaker. We will come up with something like this:


We're going to use XML importing for this.
The fields we need in the database:

id
screen_name
text
profile_image_url (just for fun)


If you're not familiar with twitter api, and the xml it gives back please check this page first:

So, we can get the timeline xml with the following url:

http://username:password@twitter.com/statuses/friends_timeline.xml


(where of cource username is your twitter username and the password is your twitter password)

You can set other parameters as well (for example count: http://username:password@twitter.com/statuses/friends_timeline.xml?count=50 if you want the last 50 tweets)

But FileMaker cannot handle this xml yet.

We need an XSL file to convert it to a format that FileMaker can understant. It's a quite simple XSL I came up with. You can download it from here. (Be sure to download the file, not open it (right click- Save as - twitter2fmp.xsl)

We need to save this file somewhere, or upload it to a webserver. I chose the second method.

Now we can do the import script. It's quite simple as well, just one script step:

Import Records [No Dialog; http://username:password@twitter.com/statuses/friends_timeline.xml?count=50;http://website.com/twitter2fmp.xsl; Update matching; Mac Roman]

That's all.
The update matching is to ensure that no duplicate tweet is put into the tweets table.

Now you can create a simple list layout, or create a portal if you wish to display the the results.

I attached a sample file, which you can download here.
Please check it, and use this technique it if you like it.

Don't forget to fill your username and password!



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.