Coming soon – Facebook Application Development, Learn by Video
posted by robert | filed under Facebook App Dev, flash/flex, news, social media, tutorials/samples
My second video2brain course is due to be released soon!
This time I’ve put together a course to take you through the steps involved in building Facebook Applications – in both PHP and JavaScript and including examples of integrating Flash content for those of you who are itching to create the next Farmville
The course is the fruit of more than 3 years’ worth of Facebook Application development experience and a fun week’s stay in Graz last month and is packed full of example code and tips for everybody who wants to get into Facebook App development!
The course will, as you may have guessed from the box shot, be available in boxed DVD form together with an accompanying booklet packed with extra tips for Flash Application development for Facebook – an area that I’ve been heavily involved in from the beginnings of the Facebook Platform for Developers. One chapter in the booklet was written by my colleague and partner in crime at Substance, Neil Young, and covers more PHP and specifically AMFPHP Gateway implementation for Facebook Applications.
Drop me a line with your email address if you’d like a heads-up when the course is available or watch this space for news!
tags: facebook, Facebook SDK, flash, video course, video2brain, workshops
Using ShareKit: Add Social Media sharing to your iOS App in minutes!
posted by robert | filed under iDevices/iOS, social media, tutorials/samples
I’ve been catching up on some iOS development and finishing off one iPhone App
(soon to be released – watch this space) and starting on my wish list for TicTacTomato v2.0, which is looooooooong overdue…
One feature I needed to add to both Apps was a share feature – share to Twitter and Facebook, to be specific. I already have an action sheet coded up in the Apps to allow a user to send an email to a friend but the other share options were outstanding.
Not being one to reinvent the wheel, I took a little surf around and found a promising little library called ShareKit, billed as “Open source, drop-in share features for all iOS apps”. Sounds good!
After reading through the docs briefly and downloading the library, I began the process of integrating it into one of the Apps. Around 15 minutes later all was coded, tested and working wonderfully.
Here’s how it went:
1. First, download ShareKit from the site: http://www.getsharekit.com/install/
2. Once it’s downloaded simply add the files contained in the “ShareKit” folder of the enclosed example project into your own project.
3. Include the following frameworks into your project:
SystemConfiguration.framework
Security.framework
MessageUI.framework
The instructions on the download page will guide you through the process of setting up your project to use the default installation of ShareKit, allowing many different kinds of posting depending upon the item being posted, but I’m only concerned in posting a text to either Facebook or Twitter so continue as follows:
4. Before you can add any code to your project you’ll need to set up a corresponding Facebook Application and a Twitter API key.
To set up a Facebook App go to http://www.facebook.com/developers/ and choose “Set Up New App”. Give your App a name and a description, enter a contact and support email address and save. There’s no need to add any further details for the Facebook App now. Keep this window open as you’ll need to copy and paste some values from here into your code soon.
Now, set up a Twitter API key for the App via http://dev.twitter.com/apps/new, making sure that Application type is “Browser” and not client and adding a description as before. The callback URL you enter can be anything as this will never be called (according to the ShareKit notes) as the call will be intercepted. Again, keep the window open so that you can copy and paste values into your code.
5. Now, back in XCode and your project, open SHKConfig.h and enter value for the following settings, copying and pasting from either Facebook or Twitter as necessary:
#define SHKMyAppName @"
#define SHKMyAppURL @"
#define SHKFacebookUseSessionProxy NO
#define SHKFacebookKey @"
#define SHKFacebookSecret @"
#define SHKFacebookSessionProxyURL @""
#define SHKTwitterConsumerKey @"
#define SHKTwitterSecret @"
#define SHKTwitterCallbackUrl @"
#define SHKTwitterUseXAuth 0
#define SHKBitLyLogin @"
#define SHKBitLyKey @"
6. Next, open the class in your project that is responsible for your “share” or “tell-a-friend” functionality – in my case a FlipSideViewController class. Import the ShareKit class headers for the Facebook and Twitter services:
#import "SHKFacebook.h"
#import "SHKTwitter.h"
7. My share mechanism (the method called when the share button is pressed) causes an actionsheet to be shown, initially only containing email as an option. Now add twitter and Facebook buttons:
- (IBAction)tellAFriend:(id)sender {
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:@"Not now, maybe later" destructiveButtonTitle:@"Send Email" otherButtonTitles:@"Post on Twitter",@"Share on Facebook", nil];
[actionSheet showInView:self.view];
[actionSheet release];
}
8. Now add code in the didDismissWithButtonIndex method for the Facebook and Twitter buttons:
if (buttonIndex == 1) {
// twitter
NSString *tweetText = @"I'm using the ***** App - the ******* for iPhone! Get the App from LINK";
SHKItem *item = [SHKItem text:tweetText];
[SHKTwitter shareItem:item];
}
if (buttonIndex == 2) {
// facebook
NSString *facebookText = @"I'm using the ***** App - ******* for iPhone! Get the App from LINK";
SHKItem *item = [SHKItem text:facebookText];
[SHKFacebook shareItem:item];
}
…and you’re done! The SHKTwitter and SHKFacebook classes will do all of the work for you, including prompted the user for OAuth access and permissions, open a dialog to display the text to be tweeted or posted to Facebook and allow the user to post. This approach uses a simple text share and will, of course, allow you to add a link (instead of the word “LINK” above, for example
). Other approaches with ShareKit will allow the posting of images and more – more than we need for a simple share option.
For the sake of completeness, here’s the email option code from my didDismissWithButtonIndex method, in case you don’t have that:
if (buttonIndex == [actionSheet destructiveButtonIndex]) {
// email
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"***** - an App for you?"];
NSString *emailBody = @"I'm using this iPhone App called ***** and thought you might like it.
You can download it here:
LINK";
[picker setMessageBody:emailBody isHTML:YES];
picker.navigationBar.barStyle = UIBarStyleBlack;
[self presentModalViewController:picker animated:YES];
[picker release];
[emailBody release];
//[to release];
}
9. Run some tests and you’ll see that the sharing functions work wonderfully. Not bad for a few minutes’ work!
Note: The only real issues I have with this library are the various semantic warnings and also potential memory leaks in the library code – some of which has come from other sources and is now a little dated. It would make sense to run an analyse on your project and go through and address the leaks yourself, just to be sure. There’s nothing worse than adding a library to your project to save time and then introducing memory leaks. Other than going through and updating some of the included C classes, however, some of the compiler warnings are going to stay.
All in all, however, a really useful library which has saved me a measurable amount of time and is very easy to use!
Go ahead and take a look at ShareKit – well worth it.
Facebook API’s ‘Invalid OAuth 2.0 Access Token’ error – a solution?
posted by robert | filed under social media, tutorials/samples
If you’re a developer of Facebook Apps you’ll be aware of the above-mentioned bug. If not, here’s a link to the bug details:
http://bugs.developers.facebook.net/show_bug.cgi?id=15933
The first thing you probably heard about it was when one or more of the Apps you’ve recently written (or are in the processing of developing) suddenly stopped working.
The bug was first reported on 17th March 2011 – pretty much the same time I realised that an App I’d written for a client and was about to release would no longer initialise properly and hence would need to be fixed. The symptoms of the problem are that, instead of the Facebook API returning a valid OAuth 2.0 Access Token, an invalid token is returned. Standard practice here is to redirect the user to a login/permissions prompt and thus start the authorisation process again.
The bug caused this process to fail consistently and many Apps simply looped indefinitely, unable to authorise correctly.
The App I’d worked on with a colleague, Neil Young, used the PHP Graph API libraries to establish a session and check for it’s validity, redirecting the user to the App’s login/auth URL if the session access token returned was not valid (or present). Once a session has been established, various Graph API calls were made to retrieve user information from Facebook before passing data into a Flash App (my part of the job).
It stopped working and looped indefinitely.
Today, Facebook (in the form of one of their staff, Douglas) responded to the priority 1 bug by saying:
We believe that the underlying issue here (cache inconsistency) has been resolved.
All of the access_tokens that we looked at fell into two categories: a cache issue or the user had logged out/changed password.
Naturally, the bug persists and a number of developers, myself included, have commented on this. Facebook have closed the bug as “resolved fixed”. Hardly.
Tired of waiting for a response, wishing to complete the App for the client and convinced that the issue is related not to changed user passwords (mine wasn’t changed) or “cache issues” (where, I ask?) but rather to Facebook having implemented undocumented changes to their PHP API to force us down the JS authorisation route, Neil and I decided to change the approach taken for the App in question:
- remove all use of the PHP API for authorisation and replace with JavaScript
- remove all PHP Graph API queries from the index.php page itself and implement them in the AMFPHP gateway used by the Flash App to retrieve database data anyway
I spent some time this afternoon removing all of Neil’s PHP-based authorisation and login/permissions redirect and replaced it with an ExternalInterface call from within the Flash App to trigger a JavaScript call to FB.login with the required permissions and the following code (abbreviated):
FB.login(function(response){
if (response.session){
if (response.perms) {
// user is logged in and granted some permissions.
// perms is a comma separated list of granted permissions
//get the user from the facebook api
FB.api('/me', function(response) {
//api call worked so tell the flash!
sessionConnected();
});
}
else{
//user is logged in, but did not grant any permissions
//build content
$("#dialogue").dialog( "option", "title", 'Permissions Error' );
$("#dialogue").dialog({ buttons: { "Close": function() { $(this).dialog("close"); } } });
var data = {"contents":{"success":0,"feedback":{"messagesType":"error","message":"You did not accept the required permissions"}}};
$("#dialogue").html(BuildFeedbackMessage( data.contents ));
$("#dialogue").dialog( "open" );
}
} else {
// user is not logged in
//build content
$("#dialogue").dialog( "option", "title", 'Permissions Error' );
$("#dialogue").dialog({ buttons: { "Close": function() { $(this).dialog("close"); } } });
var data = {"contents":{"success":0,"feedback":{"messagesType":"error","message":"You did not accept the required permissions"}}};
$("#dialogue").html(BuildFeedbackMessage( data.contents ));
$("#dialogue").dialog( "open" );
}
}, {perms:'publish_stream'});
The sessionConnected(); method simply calls a method in the Flash App via ExternalInterface to tell the App it can continue loading, at which point it calls methods via the gateway to retrieve data.
If the user is either not logged on or hasn’t granted the required permissions, a dialog is displayed asking them to do so.
This works. Even the FB.api(‘/me’, function(response) block executes without any issues. The flash receives the confirmation call back from JavaScript and continues on it’s merry way, doing what it should.
Now. My password hasn’t changed and I can’t see how any form of cache issue could lead to this solution working where the other didn’t.
I also didn’t uninstall the App or make any changes to my App permissions settings – simply made the changes mentioned above.
Maybe this’ll work for you too. It’s a solution and not a workaround. I don’t like workarounds as my clients won’t pay for me to go back in a month’s time and rework something. They expect a finished product to be a finished product – and I can’t blame them.
The problem with Facebook’s approach to their platform and to App developers is that we all have to work to a moving target, an inherently unstable platform. Such a platform is not really suitable for producing the kind of campaign-based Apps that I produce but Facebook market their platform as THE socially-aware marketing platform for campaign-based Apps.
It’s about time they started to run it like one – got some decent QA in place and thoroughly tested their releases before throwing bug-ridden code out into the World.
If you’d like to voice your thoughts on this, either do so in the comments or, better, go along to the Facebook Page we’ve set up and add your voice there:
Developers’ Rights: http://www.facebook.com/pages/Developers-Rights/206834912671201?sk=wall
Good luck in getting your Apps running!
ps. It’s worth noting that the user experience is now identical to that previously found in external website using Facebook Connect and not the seamless experience which we used to be able to offer with the REST API or even the latest PHP Graph API approach taken prior to this bug appearing. This is why I’ve labelled this post “a solution” – it’s not ideal.
Get Mommafied with Big Momma’s House 3
posted by robert | filed under flash/flex, projects, social media
After a busy few weeks working with the lovely people at Substance, I’ve managed to find time to write about the first of two projects I’ve been working on: Big Momma’s House 3 Get Mommafied!
The project involved the build and implementation of a combined microsite/Facebook App which allows the user to choose a photo of themselves from their hard disk or Facebook albums OR to take a snapshot with their webcam and then to proceed and give themselves the full Martin Lawrence-style Big Momma treatment – to Get Mommafied! They can even choose a wig or dress to suit their style
The result can be posted to their Facebook Wall, Twitter (via Twitpic), downloaded or copied as a HTML embed link for use anywhere they wish.
Substance’s Craig Beswetherick (@GrindheadGames on Twitter) was responsible for the nasty pixel manipulating stuff and yours truly wrapped it all up with the rest of the UI, Facebook goodness and functionality. The design comes from Substance’s in-house artistic guy Ewan Brock (@letsbrock) and the final site/App has been rolled out in numerous countries including the UK, Russia, Mexico and throughout Europe – resulting in some interesting challenges with sizing on buttons and text fields. Naturally, localisation was carried out by using XML for configuration and copy.
The App was built using FDT4, assets in Flash and based on PureMVC for the simple reason that I have a nice little Facebook App template built up using this framework. PureMVC is by no means “pure” MVC but having a pre-built “template” which uses such a simple-to-use framework is a definite benefit when approaching new projects.
So. Go ahead and Get Mommafied! You may be surprised at how good you look with an extra 50 kilos in a wig and a dress!
Social Media for business – why it’s important!
posted by robert | filed under social media
As many of you already know, I spend a great deal of my time working on social media application development – Facebook Apps mainly – for various clients. I’ve been developing Facebook Apps for a fair while now (check out my timeline for more detail) and have done so for both large clients (Fox International or Momentum Pictures, for example) and smaller ones in the UK, Switzerland and USA.
No matter the size of your organisation, one thing is clear: Using social media and Facebook Pages or Apps in particular are great ways to engage in dialogue with your customers. Using social media correctly is essential. Avoiding common mistakes and pitfalls is even more so. This is a subject close to my heart, so to speak.
I was fortunate enough to meet Krystena Petrakas, one of Business Wings’ Staff Writers, at the Business Startup 2010 show in London before Christmas. After talking a little about the need for businesses to embrace social media, she asked me if I’d be willing to be interviewed for a podcast to be published on their site.
The result can be found here, on the businesswings.co.uk site.
I have to confess to being late in posting this blog article and link – and hope that Krystena will forgive me for this!
Enjoy listening – and remember that this was recorded in a “quiet” corner at a busy trade show!
tags: facebook
Importing blog entries from b2evolution to WordPress 3.x
posted by robert | filed under general, social media, WordPress
After a few aborted attempts, I finally managed to import the contents of my old b2evolution-based blog into this new one yesterday evening.
The answer turned out to be as simple as other sites had suggested: Save the RSS feed of my old blog in a file and import it via the RSS importer built into WordPress. My initial attempts had failed as I had simply clicked the “reader” link in Safari and then saved the source of the displayed page. Importing that simply won’t work as Safari seems to mess things up.
So, here’s how it goes:
(ps: please check the word of warning below…)
- open up your b2evolution-based blog
- right-click on the RSS 2.0 link displayed by your skin – this is normally on the sidebar somewhere – and save the linked file on your local machine:
- in WordPress Admin, Tools, Import from the left.hand menu:
- choose RSS:
- …and select the file you’ve just downloaded before clicking “Upload file and import”
The import may take a while but you’ll soon see a list of “Importing post… done” messages and all should be good! If the import doesn’t bring in all posts from your old blog then you can check what’s been imported and remove these from the downloaded feed file before importing again.
A word of warning:
As those of you who follow me in Twitter (and were already following me last night) noticed, my WordPress blog using the TweetButton plug-in AND I had not switched OFF this plug-in before importing. The plug-in caused a tweet to be posted for every single post imported!
Thankfully, my followers are very tolerant:

OK, mostly… I did get a new mention though – for something I wrote probably a year ago
Once more, my apologies for spamming your timelines last night. I couldn’t even apologise yesterday because the large number of Tweets put me over my daily quota!
So. End-result all good. My old blog entries are now here and there’s no need for me to send site/blog visitors to my old blog. All that’s left now is for me to create some .htaccess rules to ensure that inbound links to my old blog are redirected here – don’t forget this when you import an old blog!
Happy blogging!
tags: b2evolution, new blog, RSS import, WordPress
The Social Media Experiment – or is it?
posted by robert | filed under social media

Firstly, you may ( or may not) notice that I’ve renamed the “Facebook/Twitter” category on this blog to “Social Media”. Why? Read on…
I have been involved in the development of Facebook Applications for what seems like an eternity. In fact, my first Facebook App, Garfield Photo Invader*, dates back to November 2007!
My presence on Twitter started also quite some time ago and I’ve sent out 4,909 Tweets to date – not a huge amount by some people’s standards, but still indicative of some level of engagement
None of this makes me a “Social Media Guru”. If anybody ever calls me a “Social Media Guru” I will probably not have very kind words for them – it’s a stupid and meaningless title. What I would say is that I’m a sociable person – both online, and off. Social Media has brought me into contact with many people whom I would never have met otherwise – particularly in Switzerland, where I live.
What I’ve now started to do is to try out other forms of Social Media. That’s why the category name has changed. It’s about more than just Facebook and Twitter. It’s also about DailyBooth, Flickr, Foursquare and (dare I say it) Ping.
Over the next few weeks, I’ll be working with all of the above to see how they can enhance my life. It may be that they don’t. They may just become distractions and demand too much of my time.
This is what I’m calling my “Social Media Experiment”. It might seem a bit late for some of those reading this but I am somebody who only uses any form of technology, hardware or software, if it’s of any use in enhancing my life. The result of the experiment will be that I’m either more present in more ways on these platforms – or that nothing changes. We’ll see!
There will be posts here relating to the experiment and to any conclusions I have made along the way. Please feel free to come back and check, comment or compare your experiences!
Meanwhile… see you on the interwebs!
* Sorry – it’s offline now
Cartoon credit: HubSpot on Flickr
Join the Coca Cola SWAT Team Switzerland and go to New York!
posted by robert | filed under social media
How cool is that then?
Not only are there great prizes up for grabs, but the website is really nice – I love the helicopter preloader:
(click the image to go to the site…)
There are some really fun videos on the site too, like this one:
OK, so it’s an old theme – but on a massive scale – could this be a new form of transport? ![]()
Think you can do better or want to show off with some crazy stunts? Then sign up and upload your video!
The website is in German and French and they’re on Facebook too:
Facebook IPO not likely this year…
posted by robert | filed under social media
According to Bloomberg, Facebook aren’t set to go public this year after all – despite expectations…
It seems that Mark Zuckerberg was being his usual open self when asked about the subject on TV recently. According to the Bloomberg article:
Zuckerberg, in a television interview this month, said Facebook will go public “when it makes sense,” without elaborating.
Let’s face up to some facts, shall we: It may never make more, or less, sense for Facebook to go public. That particular response from Mr. Zuckerberg is not exactly the sort of eloquent insight we’d expect from the figurehead of a multi-national multibillion dollar phenomenon such as Facebook. Maybe that itself is a clue to why Facebook shouldn’t go public yet: More time is needed for Mark Zuckerberg to mature, to learn about running a public corporation and to take responsibility before he can really be forced into that role. Maybe he’ll never lead the company once it’s gone public? It’s a challenge.
Another reason it’s a good thing:
The extra year will certainly give him, and his close management team, a chance to finally get really in touch with developers – something which is not only sorely needed but also seems to line up with the stated strategy, according to the article:
…venture capitalist Jim Breyer, a member of Facebook’s board, said in January that the Palo Alto, California-based company isn’t focused on a 2010 sale. Instead, Facebook’s management is trying to woo more users and developers, Breyer said at the time.
So, Facebook. You want to “woo” users and developers? Cool. When are you going to start?
Woo users by making it clear what the privacy settings mean and make the defaults clear. Clear communication is the only way to stop people being upset. Just remember that most people who use Facebook aren’t US college-kid geeks and learn how to communicate with them.
That’s users. Developers are a little bit different, and the same. We want to have clear communications too – and rely on them. Your platform would be a lot less interesting and nowhere near where it is today without App developers. Talk to us. Tell us when new features are coming and, more importantly, when existing ones are going to be radically changed or simply switched off. Your approach to informing and supporting developers is, at the moment, severely lacking. Fix it. Woo developers by helping them to use your frankly more than dodgy and badly-documented platform.
One other thing: Most of your users and developers are not even in the US. Think global and don’t impose an American way of thinking and doing business on those outside of the US.
Once you’re finished wooing, and Mark Zuckerberg has had a chance to mature a little, you can change the company culture to make it more friendly and less “take it, or leave it” when it comes to those who raise issues.
If you can spend an extra year and focus on those things then Facebook will really be a good and ethical company to invest in. Sure, people will invest without you being “nice” or more ethical. It may just help, however, if you are…
I’d certainly like to see it.
to Like or not to Like…
posted by robert | filed under social media
If you look at the bottom of this post (or any other post on my blog, for that matter – hint, hint) you’ll find that I’ve now added the almost ubiquitous Facebook “Like” button functionality to this blog. I decided it was time and had a few minutes spare in which I could add it… to give you a chance to say how much you enjoy my posts! ![]()
The Like button and the little “thumbs-up” icon are becoming a massively-popular meme throughout the offline world with stickers, graffiti and even advertisements echoing the “I Like” sentiment. Coincidentally, I found something related while checking through today’s links on notcot.org:
If you want to be able to mark your preference, or indifference, on physical objects, you can now do so with these wonderfully analog rubber stamps from Nation:
Now you can not only show your appreciation for content online, but you can print it and stamp it with your approval aswell!







