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.

10 comments:

  1. This method does not work anymore do you have any update?

    ReplyDelete
  2. Not yet, I'm very busy at the moment, sorry.
    You should check the new twitter api as it requires Oauth authentication.
    The technique I wrote used basic authentication, and it it deprecated:

    http://apiwiki.twitter.com/

    Oauth is the way to authenticate.

    http://dev.twitter.com/pages/basic_to_oauth

    There are some javascript libraries for that, so maybe it could be implemented that way using a web viewer.
    Will take a look at it as soon as I have time.

    ReplyDelete
  3. Thanks I think I will wait for you, I am not tech-savvy at all :( but I will start reading in the direction you are pointing to thanks!

    ReplyDelete
  4. Ági, found another way:
    http://dev.twitter.com/anywhere
    Register your app there, get your api key.

    After that, read this: http://dev.twitter.com/anywhere/begin
    There is a "Configuring the Tweet Box" section.
    That way you can easily implement this in a web viewer.
    by loading the the anywhere api (Getting Started section sample code), and that tweet box.
    It's just simple html. You just need to merge them, export it to a temporary path, then display in a WebViewer. Easy.

    Sok sikert.

    ReplyDelete
  5. Do you know of any cross-platform way to get the result of the POST?

    ReplyDelete
    Replies
    1. working on the same thing....so far I have not had much luck but to try out some of these things, apigee.com has some great api testing console stuff you might find helpful. Please post if you get it working. I will do the same :

      Ken

      Delete
  6. It works for me. I like the simplicity that you use. I'm trying to learn python to make my website more dynamic, but my friend keeps telling me it's better to go for Java. What is FileMaker coded in? C#?
    http://www.zerobluetech.com/custom-filemaker-development/

    ReplyDelete
  7. I really appreciate you for all the valuable information that you are providing us through your blog. if any one want more information about Filemaker developer visit:- Iavenue.ca

    ReplyDelete