I’ve recently had feedback from one or two “Facebook Application Development” course students who’ve ran into the infamous “error 191″ problem when trying to run their Facebook Apps.
Normally this error is caused by using an incorrect URL in the ‘redirect_uri’ parameter for getLoginUrl when using the PHP SDK, for example:
$loginUrl = $facebook->getLoginUrl(array('scope'=> 'user_checkins','redirect_uri'=> $app_url));
Another potential cause of this error is mixing your http: and https: URLs or assigning a http: URL to this parameter when the user is actually using a secure https: URL to access your App.
When I recorded the Facebook course the need to check the protocol and assign the correct http: or https: URL simply wasn’t there. Now we need to do this. Many users have switched over to using Facebook over a secure connection and Facebook will also switch off support for http:-only Apps anytime soon (as usual, no exact date).
Here’s a little snippet you can use to check for the protocol being used and assign the ‘redirect_uri’ correctly:
$protocol = ($_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
Then simply prepend $protocol to your ‘apps.facebook.com/…’ string to form the URL.
If that’s not the issue and all seems to be fine, all URLs look right and you simply can’t see what else could be wrong, then don’t panic: Stop pulling your hair out
Have you set up an App Namespace in the Developer App?
It turns out that, if you don’t set this and use the APP NAMESPACE to refer to the App, you can get the dreaded 191 error. Set it and use it in your redirect_uri instead of the FB-generated App ID number.
When I recorded the course, the App Namespace was generated and used by default to reference the App. Hence the problem didn’t arise. This is one of the things that have changed since the course was recorded.
- Check that your URLs and protocols match – both in the Developer App and in your code.
- Assign the correct protocol when assigning the ‘redirect_uri’ parameter for getLoginUrl().
- Use the App Namespace and not the App ID to reference your App on apps.facebook.com
There have, of course, been many more changes in the World of Facebook App Dev since I recored the course – even since it’s release. Watch this space for more updates over the next few weeks!
Happy Facebook App-building!
Last week’s big news from video2brain was the launch of a new subscription model for ALL video trainings in the English-language course library!
Take a look at this short video to find out more:
The subscriptions are available in either Platinum, Gold or Standard form and give you instant, unlimited access to the English-language Video Training Library™. There are currently 132 courses available, with 5,877 video lessons, with new courses added throughout the month. A subscription lets you learn anytime you’d like and keep up to date with the latest software and techniques.
There’s also a special $12.99 per month launch promotion running for a limited time so sign up quickly to take advantage of the offer!
Have fun learning!
This week I received an exciting parcel from my friends at video2brain:
Yes – the Facebook Application Development : Learn By Video Workshop DVD and book is here! I’ve checked around a few booksellers online and it’s shipping now!!!
Amazon.co.uk appear to be currently out of stock (good news for us, but not so good for you I’m afraid) but the .com link above should find some copies still in stock at the moment. Grab one quick – they’re going fast!
The benefit of owning the DVD course, apart from the nice packaging, is that you’ll also receive a copy of the accompanying 48-page book which builds on course content to discuss in more detail the building, and integration, of Flash/Actionscript-based Facebook applications – including a chapter on building a Facebook PHP framework and AMFPHP Gateway for use in Flash-based applications by my friend and daily colleague in the world of Facebook Development, Neil Young. Thanks Neil!
The book adds a lot of value to the course if you’re going to be involved in creating interactive Flash-based Facebook applications and I’d certainly recommend buying this edition of the course!
Don’t forget – Christmas is coming!
My second video2brain course is due to be released soon!
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!