How to link your Twitter to FileMaker

 In API, Email, FileMaker, FileMaker Pro, SendGrid
how-to-link-your-twitter-to-filemaker-appica

An active social media presence is becoming an ever more essential element of operating a modern business. In Australia, Facebook dominates the social media space with 12 million Australians using Facebook on a regular basis. While Twitter continues to rise in popularity lifting from 19% to 32% according to the latest Sensis data.

In a nutshell, Australians of all demographics are adopting social media – fast. Not just on the most popular platform, Facebook – but Twitter, LinkedIn, Instagram, and Snapchat as well. We’ve all heard from a thousand articles already about how important it is to engage with customers on social media; but doing so over such a range of platforms is time consuming.

For FileMaker users it doesn’t have to be so hard. Your custom business app is able to integrate with your social media accounts and do the heavy lifting for you. We’ve found that Twitter is the most difficult to integrate given it’s restrictive character limit and posting format. Coupled with it’s growing userbase in Perth, we feel it’s important to walk you through how to integrate your Twitter with your FileMaker app.

Lukily – DB Services in the US has done an excellent job writing up how to integrate FileMaker with Twitter, answering a question we’re often asked by clients and other Perth FileMaker developers.

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!

If you have any issues or would like to speak to one of our Perth FileMaker Consultants – contact us here or give Appica a ring on (08) 6555 2520

Recommended Posts

Leave a Comment

How to send HTML emails in FileMaker using API calls with SendGrid