Local Development For Heroku Facebook Apps

May 12, 2012 at 12:09 (Development, Facebook, Tech)

Disclaimer: At the moment this is mostly a brain dump because I don’t want to forget everything I seem to be having to do to get this setup

When Heroku and Facebook joined together it seemed like a great way for me to get back into development without having to worry about sorting out some new hosting and other things that I didn’t have time or money to invest in just to play around some more.

Heroku have a good getting started tutorial and sample app:  https://devcenter.heroku.com/articles/facebook

which was all going fine until “For development, you’ll need to register another app with Facebook. Unlike the first app, this one will not run on Heroku, but instead will run on your local workstation”. This did make me wonder if both Heroku and Facebook are going about things the wrong way. Shouldn’t the first step be teaching people how to develop locally and then deploy live. I’d have hoped that Facebook would do more to provide support for development versions of apps instead of manually having to duplicate everything. Interestingly I just read this blog about the lack of fundamentals in web programming education which I completely agree with.

The first problem I had was setting the facebook app env variables. This meant setting up a virtual host and was back to all the things I didn’t know about and wanted to avoid. I followed the instructions but it didn’t seem to work.

I hacked my way around this to get things working by adding the following code to the top of the AppInfo.php file


Not nice or recommended but it allowed me to make some progress.

Although not much progress, I was now getting through to Facebook but not getting much further and failing to authorise and no clues as to why. I now can’t remember the exact details but somehow debugged the code  in FBUtils/login.php to find out why nothing was returning from the CURL request (something else I knew nothing about). Turned out the problem was because the app was not being accessed via https, something all Facebook apps now need to do.

The next step was therefore to setup SSL on my local WAMP setup. I found several different articles on how to do this and tried a few all without any success. Finally I found this http://www.phpjoel.com/2011/04/07/installing-ssl-using-openssl-on-a-wamp-localhost/ which was not only the simplest example it also seemed to work.

I had to debug one final problem by running httpd from the command prompt which told me there was a syntax error on the CustomLog in httpd-ssl.conf, I added in an extra quote and everything now seemed to be working. When I say working, I mean working a little more. I could now access my localhost via https and the Facebook app was attempting to verify. Unfortunately I was now getting errors back from Facebook “API Error Description: The specified URL is not owned by the application”. From the URL it looked like this was still trying to access http rather than https and I just needed to update the configuration settings of the app. I’ve tried changing the URL but it’s still not working, I’m hoping this is just a matter of waiting several minutes to propagate to all servers but it’s been a while now and it’s still not working. Considering I first started the Heroku in February I’m pleased to finally have it working this far and will have to come back to work out what’s wrong with the configuration some other time.


Permalink 1 Comment

A Simple Framework

April 16, 2011 at 16:32 (Development, PHP) ()

For many reasons I’ve been wanting to develop something new and from scratch for quite a while. Mainly because most of the coding I do seems to be tweaking existing code or copying and pasting existing structures. After reading a few different tutorials on building a MVC Framework I thought I could join every developer and their dog and have a go at building a framework of my own. It was intended as an educational exercise for myself and so I’ve kept things as simple as possible, especially for the first version. It’s not an MVC framework as I haven’t yet included any support for models. At this stage it’s Controller Action View but it is more or less working now. I still need to finish it off and then decide how practical it is to actually build something with.  Who knows, I may then even release it for scrutiny from others.

In true He-Man style here are a few things I’ve learnt (or rediscovered) in the process:

  • mod rewrites may well be working but just redirecting to the wrong place and producing page not found errors
  • setting <base href> won’t work in IE if you have invalid html before it (during debugging)
  • There’s no need to use DIRECTORY_SEPARATOR constant (I didn’t even know it existed) when building paths as a forward slash will work in Windows
  • You can use reflection to check the number of required arguments when dynamically calling functions


$method = new ReflectionMethod($controller,$action);
$requiredArgs = $method->getNumberOfRequiredParameters();

Permalink Leave a Comment