Feeds

Surviving the Facebook app 'swamp' with Azure

Cloud platform, cloud client. Is Facebook and Microsoft Azure the perfect fit?

Secure remote control for conventional and virtual desktops

“Developing with Facebook is like building a house on a swamp,” says Microsoft’s Nathan Totten. He should know. He used to work at social media company Thuzi, and when the company needed to write a C# Facebook application, he and his colleague Jim Zimmerman were so disappointed by the existing C# SDKs that they built their own.

Nathan Totten, technical evangelist at Microsoft. Totten is now a technical evangelist at Microsoft, and his project has become the open source Facebook C# SDK with a measure of approval from Microsoft as the suggested way to build C# applications for Facebook.

So why is Facebook development swamp-like? The first problem is that the Facebook API changes over time, and any wrapper you build on top can soon get out of date. The second problem is that Facebook does not officially support C#. It has SDKs for JavaScript, Apple iOS, Android and PHP.

In mitigation, the dynamic features of C# 4.0 are actually well-suited to APIs that are in flux, as Totten explains in his post mentioned above. Some API changes and additions can be accommodated without changing the SDK at all. This has also made it possible to make the C# SDK somewhat similar to the PHP SDK, which is an advantage when you are consulting the Facebook documentation.

Nevertheless, there are challenges. I tried the SDK with a simple Facebook canvas application, hosted of course on Azure. A canvas application is one that is embedded into a Facebook page. I started with an ASP.NET MVC 2.0 application, then added a reference to the Facebook C# SDK using NuGet, Microsoft’s package manager.

Facebook and Azure screenshot

Up and running: a Facebook Canvas app written with C# and hosted on Azure

To develop the app, I configured the application on Facebook to link to the web page running on localhost. Facebook apps generally request permission from their users to access personal information. In principle, the Facebook C# SDK makes this easy by using attributes. My app queries user status, so I annotated a method with:

[CanvasAuthorize(Permissions = "user_status")]

At runtime, Facebook popped up a dialog requesting permission. Easy. Unfortunately I soon ran into problems. After the user grants permission, you have to include an access token in calls to the Facebook API. There are several kinds of access token, and getting this right can be tricky.

Simple attributes in the code prompt the correct Facebook permission prompts.

I also discovered that the Facebook C# SDK is barely documented. A documentation link on the open-source site has no reference material, just a few examples and links, some of them out of date. Another problem cropped up.

I deployed my working app to Azure and it no longer worked. The reason, I discovered, is that some browsers block cookies from sites running in iFrames. If you ever have to debug a problem like this, which works locally but not on Azure, you will be grateful for an Azure feature called Web Deploy.

Normally, whenever an application is published to Azure, the cloud platform creates a new virtual machine, copies it, and then spins up the copy. This is why publishing to Azure takes a long time. Web Deploy, by contrast, updates the application on an existing VM, which takes only a moment.

Once you have debugged successfully, you still need to publish properly as otherwise the VM may revert to the original upload. There are hassles then, and it is curious that Microsoft and Facebook have not done more to make it easy to build C# Facebook applications. Having an open-source library is all very well, but it needs proper documentation, as does the companion Windows Azure Toolkit.

Once you have the plumbing right though, there is some sense in it.

Nothing insurmountable

Enteraction, a UK games company, uses Azure and the C# for its social media gaming framework, called GameShaper. According to operations director Arthur Barker, Azure provides scalability while being compatible with familiar Microsoft-platform technologies.

Developing with Facebook is like building a house on a swamp

Enteraction uses the Facebook C# SDK to get round Facebook’s lack of support for C# and .NET. “We have experienced a few teething issues, but nothing insurmountable nor unexpected for an SDK of limited maturity,” Barker told me. “Overall we are very happy with Azure.”

It is not essential to use the Facebook C# SDK, and another developer told me that he prefers to roll his own; it may take longer, but at least you know how it works.

Nevertheless, from the point of view of Facebook integration, using C# instead of PHP does feel like rolling a ball uphill. Then again, the integration points are likely to be only a small part of the whole, and if Visual Studio and Microsoft SQL Server are familiar, the benefits of using them can outweigh a little pain at the Facebook end. ®

Internet Security Threat Report 2014

More from The Register

next story
Cray-cray Met Office spaffs £97m on VERY AVERAGE HPC box
Only 250th most powerful in the world? Bring back Michael Fish
Just don't blame Bono! Apple iTunes music sales PLUMMET
Cupertino revenue hit by cheapo downloads, says report
The DRUGSTORES DON'T WORK, CVS makes IT WORSE ... for Apple Pay
Goog Wallet apparently also spurned in NFC lockdown
Microsoft brings the CLOUD that GOES ON FOREVER
Sky's the limit with unrestricted space in the cloud
'ANYTHING BUT STABLE' Netflix suffers BIG Europe-wide outage
Friday night LIVE? Nope. The only thing streaming are tears down my face
Google roolz! Nest buys Revolv, KILLS new sales of home hub
Take my temperature, I'm feeling a little bit dizzy
Cisco and friends chase WiFi's searing speeds with new cable standard
Cat 5e and Cat 6 are bottlenecks for WLAN access points
prev story

Whitepapers

Cloud and hybrid-cloud data protection for VMware
Learn how quick and easy it is to configure backups and perform restores for VMware environments.
Getting started with customer-focused identity management
Learn why identity is a fundamental requirement to digital growth, and how without it there is no way to identify and engage customers in a meaningful way.
Reg Reader Research: SaaS based Email and Office Productivity Tools
Read this Reg reader report which provides advice and guidance for SMBs towards the use of SaaS based email and Office productivity tools.
Intelligent flash storage arrays
Tegile Intelligent Storage Arrays with IntelliFlash helps IT boost storage utilization and effciency while delivering unmatched storage savings and performance.
The next step in data security
With recent increased privacy concerns and computers becoming more powerful, the chance of hackers being able to crack smaller-sized RSA keys increases.