Blog

Software tips, techniques, and news.

FileMaker Twitter Integration

As one of the top social media platforms, Twitter has over 300 million active users worldwide. Leveraging FileMaker technology, developers can build custom apps which interact directly with Twitter. Let's walk through how to get your app connected to Twitter.

youtube-preview

Creating a Free Developer Account

First, log into Twitter and create a Twitter App. Second, click the button to generate an API consumer key and an API consumer secret. These two strings are used to securely authorize actions with your twitter account. The consumer key will be passed back and forth with each call, serving as identification. The consumer secret is used to securely encrypt the call in a specific way unique to your account.

Authenticating with Twitter

Once you have your API information, you will need authenticate your solution with the Twitter API. Twitter API uses a OAuth, and there are two types. Basic authentication can be used for actions which do not require user context, such as reading public tweets or getting profile information. User authentication on the other hand, is needed for actions which require an account: tweeting, direct messages, etc. For this example we will use basic authentication to get the number of followers and tweets of any Twitter handle.

The first step is to use a combination of the consumer key and secret key to obtain an access token. These two keys must be combined, separated by a colon, and encoded with Base64. Leveraging the Insert from URL [] script step, FileMaker is able to make HTTP calls and get back the responses. This is the basic mechanic of working with API endpoints.

The token is returned as a JSON string, which FileMaker can easily read with native JSON functions. If you authenticate again, you will be given a new token and all old tokens will become invalid. This process ensures tokens cannot be obtained and used without your permission, and also reduces the exposure of your consumer key. To get the token, POST a request with the following settings and headers:

Request Example: POST https://api.twitter.com/oauth2/token
Headers: Authorization: Basic (Insert Base-64-Encoded <consumer key>:<secret key>)
Headers: Content-Type:application/x-www-form-urlencoded;charset=UTF-8
Body: grant_type=client_credentials
Response: {"token_type":"bearer","access_token":"AAAAAAAAAAAAAAAA..."}

Making Requests and Parsing the Response

Once the token is acquired, calls to other API endpoints can be immediately performed. Each subsequent call will be made with the token. To get information about any Twitter handle, POST a request with the following settings and headers:

Request Example: GET https://api.twitter.com/1.1/users/show.json?screen_name=<screen_name>
Headers: Authorization: Bearer <token>
Response:
{
 "contributors_enabled" : false,
 "created_at" : "Sun May 25 07:09:41 +0000 2008",
 "default_profile" : false,
 "default_profile_image" : false,
 "description" : "We build custom applications for business. Our mission is to make organizations more efficient and effective.",
 "favourites_count" : 26,
 "follow_request_sent" : null,
 "followers_count" : 303,
  ...
}

This particular use case for automatically getting Twitter followers could be useful to streamline a review process where applicants must have an audience, such as authors, reporters, or podcast creators. There's so much more you can do with the Twitter API.

Conclusion

Use the power of FileMaker to make sense of data from anywhere on Twitter. Track employee engagement, see what the competition is up to, or post tweets directly from your app!

Tweet at us if you found this post helpful - let's have a conversation @dbservices.

Did you know we are an authorized reseller for Claris FileMaker Licensing?
Contact us to discuss upgrading your Claris FileMaker software.

Download the FileMaker Twitter Integration File

Please complete the form below to download your FREE FileMaker file.

First Name *
Last Name *
Company
Email *
Phone *
FileMaker Experience *
Agree to Terms *
emory brown headshot.
Emory Brown

Emory is a Certified FileMaker Developer and former DB Services employee.