jordan
jordan

Reputation: 10792

Developing a Facebook canvas app locally - (MAMP, Codeigniter)

I am starting my first Facebook app, hosted on Heroku. I have set up an app on Heroku for production and a separate app running locally on my own machine for development. Currently, the app (which has very little functionality) runs on localhost just fine. But I don't understand if the app should be able to run like a typical canvas app on the localhost with Facebook functionality. For example, will the Requests Dialog run in a canvas app locally. Should I be able to use that functionality locally as I develop? If so, what steps do I need to take to get that working?

Upvotes: 2

Views: 936

Answers (2)

Guillermo
Guillermo

Reputation: 185

But I don't understand if the app should be able to run like a typical canvas app on the localhost with Facebook functionality

Your app should behave the same way whether it is on localhost or on the final production server.

Facebook dialogs (requests, messages..) should display on your local (dev) machine as they do on the live server. In my case to make this work I setup a secondary "facebook app" with different values for App Domains, Site URL and Canvas URL.

This allows you to run your app from localhost. If you app is canvas-only it will run inside an iframe (which points to Site URL) but will be displayed within Facebook.

Also, make sure you're including Facebook's JS API if you want to see any of the Facebook modal boxes rather than pop-up windows.

The only difference you should notice is that if you share a page from your localhost dev site via the FB API, Facebook won't be able to crawl your site and get any icon, image or description should it need to.

Upvotes: 2

Simon Boudrias
Simon Boudrias

Reputation: 44629

The differences
The only real difference between a standalone site and a canvas app (or page tab) you'll see is that you won't have a signed_request passed in when you load your page.

App dialog will still work, but in popup instead of directly on the page. Plus, you'll be able to login user like you would if you set your local dev URL (eg http://localhost:5000) in the Facebook app settings under "Website with Facebook Login" (or mobile web).

There's also some stuff you won't be able to test on the server like realtime update where facebook send a request to your site to notify an update.

There may be some other things, but this is what I can think about right now.

Working locally
So, what I usually do, is develop it locally. To manage the missing signed_request, I only provide a stub one or I just don't count on it being present so my app can run out of facebook too.

For login methods, I tend to rely only on the JS SDK as most of server side login through a canvas app will rely on the signed_request - and enaway, I found the UX login better via the JS SDK.

Then, I only setup two FB app, one staging and one for release. The staging app point to my locals urls so my Facebook will allow connection from it.

At this point, it should mostly work fine out of the box!

Upvotes: 4

Related Questions