Can I include Facebook login/API calls *without* hosting my web application online? - facebook

I'm having some trouble understanding the steps I need to take in order to make basic requests to the Facebook API. I've been reading the documentation, and having a play with the Graph Explorer, however I'm a little confused getting started.
I'm making a game application for a University submission, for which Facebook integration is a small but important part. I will be submitting this application on disk, and it will need to work when the HTML page is launched from this disk - this is where I'm getting a little stuck. I'm not sure if I'm overthinking this, but I seem to need to register as a Facebook Developer and set up an application domain. Is this necessary? I won't be able to host this application online, it will have to be submitted on disk.
So, my questions are -
Is it possible to include basic Facebook integration without hosting the application online? (Login, retrieval of a list of the user's friend's ids)
(If this is possible) what do I need to do to handle the basic 'setup' of Facebook integration? I've been looking at the Javascript SDK reference and I see I need to have my appId and channelUrl for the Loading and Initialization. I see the appId quite clearly in the App Dashboard, however it is the channelURL I am having trouble with.
I hope that makes sense :) Loading and initializing the framework and then making Graph API calls seems pretty straightforward - I'm just not sure if it's possible without hosting the application online.
Cheers!

Your page should at least be reachable via HTTP – so put a portable webserver (could be a portable Apache distribution, or something smaller) on your “disk” as well, and run your app using http://localhost/…. Add that same address (protocol and domain only, no path) in your app settings for “Website with Facebook login”.
And for the channelUrl, see https://developers.facebook.com/blog/post/2011/08/02/how-to--optimize-social-plugin-performance/

Related

Full Facebook PHP SDK app (no JS SDK). Is it even possible?

In my work we often need to build Facebook apps in the form of Facebook Canvas and Website. These apps are available on Facebook direclty (an iframe) and as mobile versions (outside Facebook, in the browser).
We are working with a code base which mixes Facebook JS SDK (authentication and authorization) with PHP SDK (API calls). I find it rather dirty, and not easy to understand for people freshly working on the projects.
It's inconvinient to make API calls with JS, and making them with PHP forces extending access tokens. Authenticating user with JS SDK involves client-side redirects which are ugly to be honest, as they usually occur moments after the current page starts rendering, and so on...
I googled a lot about separating these two SDKs but did not find a clear answer to my questions:
Is it possible to create Facebook app (Canvas, Website) which bases ONLY on PHP SDK? Check login status, login, permissions, making API calls, etc. Would signed request be enough?
Is JS SDK the only full-proof way to determine user's login status at any time?
This link seems to describe what I'm thinking of, however the docs are rather brief (which seems to be a problem of Facebook documentation in general). Can anyone suggest other sources that might help? Does anyone have experience with builing FB aplications based only on server-side?
Thanks.
EDIT:
The link I posted above covers the case of not using ANY SDK, so no, it's not what I'm looking for.
You can even create an App WITHOUT any SDK - with simple CURL calls, for example. So yeah, it is indeed possible to use the PHP SDK only, but the login process is much better with the JS SDK (no redirection needed) and you can´t auto-refresh a user session like it is possible with FB.getLoginStatus afaik.
In short, i would not recommend it, the JS SDK is the very best way to authorize users and refresh Access Tokens. I would only use the PHP SDK (or simple CURL calls) for stuff that MUST happen on the server, and for stuff that includes using the App Secret, for example.

Web API FB OAuth? How would to go about implementing it in a SPA application?

Documentation on the net seems to be VERY scarce. The only option I can think of at the moment
is to have my SPA app break convention and to have the (initial) logged out page be different to the logged in one (eg my app).
My app is built using Durandal 2.0.0.
In one of my OAuth tests app's I've managed to implement this link successfully. But as Durandal does not work in the same way (Server-side controller, & razor views), I'm thoroughly confused in how to achieve what I want to.
I'd like to have my app remain a single page app. But I've got little to no experience with the OAuth SDK
My only requirement is that the user log into my app using his FB account.
I've had an initial stab at this using the FB java script API, and got it working, but after discussions with another developer this side, it doesn't seem like the purpose of the java script API is to facilitate secure application login's? As the way we had it, would allow any user to pass a valid fb userId, then he would be logged into our app. :/
How would I go about achieving this process flow in a Durandal/Web API Single Page App?
User logs in using fb ->
then on the server we get his fb userId ->
retrieve our internal appID
I'm not asking for a complete answer/for someone to do my work....
But any documentation to get me started/less confused would be greatly appreciated.
Here is a sample project which demonstrates how to use OAuth with Durandal and Web API:
DurandalAuth.
However there are some modifications in viewmodels needed, since router changed in Durandal 2.0.0.

Canvas app using the FaceBook 3.1 API?

I used to develop a few FB apps in the past (using the old rest-ased api), and now I'm considering to make them actually usable again by porting them to the new 3.1 API.
Sounds nice, but for some reason this is way harder than I should be...
So here are few questions:
Is there any example of a canvas app using the 3.1 API? Google did not give me anything useful
Is there still a difference between iframe and FMBL canvas applications? In my app settings, I checked the fmbl-option, but when I'm back at the app overview page, it still says it's an iframe app.
The SDK mentions the getUser() function to get the user-id, but how do I request the necessary permissions for my app? When I do some googling, I find even another solution which calls a specific url and then performs a callback. This solution however doesn't seem to php sdk at all!
Where is the documentation of the php-api? The only usable thing I find is this: https://github.com/facebook/php-sdk which consists only a few lines of code. And I suspect this is for having a fb login-button on your own website, not for a canvas app.
Firstly, good luck, and best wishes - you'll need it. Maintaining Facebook apps is way harder than it should be, because Facebook doesn't believe in legacy support, changes things all the time, and deprecates things quickly and completely. As a (former) Facebook app dev myself, I can tell you there is only one constant: apps will die if you leave them alone. As an app developer, Facebook owes you no favors, and it is vicious when it comes to breaking apps.
As for specifics: as of June 2012, Facebook has deprecated and removed FBML and the REST API, and there is no longer any difference between canvas apps and iFrame apps. This isn't a soft, "you shouldn't use it" deprecation - it's a hard, "your apps are now broken" deprecation. All apps are now iFrame apps, as there is no longer any other way to build them. The docs on how to build a canvas/iFrame app are here, and there's an auth migration guide that may be helpful in conversion. Oh, and you'll need to get your app running on HTTPS too, if you haven't already.
As for the rest of it, it sucks, but the only way you're really going to be able to maintain and get your application working is using the Open Graph API. Using the PHP SDK, you just run $facebook->api('/graph/url/here') - for instance, to get user information, run $facebook->api("/$userid"). You get the URLs off of the Open Graph docs - just grab everything after the graph.facebook.com bit and pass it to api(). It's another learning curve, and (depending on the complexity/modularity of your code) is anywhere from a lot to a nightmarish mountain of changes, and there are no drop-in replacements. Sometimes you can use the old REST api, but I doubt that will last very much longer either. It's painful, but that's how it goes. You're at the mercy of Facebook, because it's their data.
Upgrading apps involves a shift in thinking: apps are now literally just webpages surrounded by the Facebook chrome. There is now no difference between an external website that uses Facebook's api to pull in information and an app that runs inside of Facebook. It's for that reason, personally, that I've shifted to just that for my own app - an external website that just happens to use Facebook for most of its posting/sharing/user info needs.
For authorization, you request permissions via OAuth, using any number of methods. There are docs on how to do that over on Facebook as well. Specifically for the PHP api, you generate a URL using getLoginURL() and then redirect to it. Facebook eventually redirects back to a URL you specify with info about whether they authorized your app and such, after which you can do a getUser(). If you want fancy/slick/user-friendly popup dialogs without a bunch of redirecting, the Javascript SDK is your friend.

Creating Facebook App

Im new to facebook applications. I recently created a webapp that consisted of html & php. But recently Ive decided that integrating my webapp within facebook would be useful. Any tips on where to start? Ive looked over developers.facebook.com and im confused. It appears they are in the process of updating. Ive come across a few guides but there from a few years ago. This app will run completely within facebook and im probably gonna have to rewrite all the code. Any guides or suggestions?
Thanks!
You didn't specify the programming language you're using but if you're developing asp, start by looking into Facebook c# sdk here: http://facebooksdk.codeplex.com/
If you're using any other language (i.e. php), try looking into respective software dev. kits (i.e. facebook php sdk). They will facilitate your job in comparison to starting raw development all by yourself.
Tim, if you want to get into the business of working with Facebook, you need to know right away that they are always in the process of updating. That being said, you should learn some Facebook terminology so you can do more research and figure out what you want to do.
Applications that run within the Facebook interface are called Canvas Apps. Your application is hosted on your own server, and Facebook simply adds an iframe in their UI that points to your app's URL.
Another way to go to create a webapp that uses your own design, but still utilizes a single sign-on system from Facebook. This used to be called a Connect App but now they don't really have a name for it. Basically, you can use Facebook's authorization system to pull Facebook user data into your own database, which basically eliminates the need for a registration page. The authorization system prompts the user to allow your app to get specific data about them - once they authorize it, your app has access to do whatever the user gave it permission to do.
The best document to wrap your brain around is about authentication: http://developers.facebook.com/docs/authentication/
Give that a whirl, and good luck!

Facebook application load testing

How can i make load testing to facebook application?
Facebook prohibits the use of automated tools!!!
You should just load test your code, not Facebook's. Your app should be an iframe app, so it shouldn't be hard to load test outside of the Facebook platform. Just disable the Facebook calls.
Facebook has a much bigger setup than you and can handle a much larger load than your load testing tools could probably generate. And if Facebook is having load issues, there is nothing you can do about it anyway.
I've been developing Facebook apps for about 3 years. Facebook does have issues fairly often, but there is nothing you can do in your app except add error capture, retry and/or recovery.
What you're looking for is a tool called FriendRunner (www.friendrunner.com) which will allow you to load test a Facebook app WITHOUT modifying it, so you don't have to comment out any API calls. This will give you the most authentic results.
They can also simulate all kinds of strange situations and problems with the Facebook API so you can see how robust your application really is.
Is there a way to decouple your app from Facebook for the purposes of load testing? You can probably assume that the facebook platform can handle everything you throw at it, so you really just need to test your custom code. Once this works without any load problems, you should be good to go (assuming you can properly deal with unusual cases like facebook being down/the api being down).
We've used the approach suggested by Brent Baisley and it's a good approach, but I've always begrudged the extra work of toggling FB apis to test the app. We are trying an approach right now that should allow you to load test most apps directly in the FB canvas.
From Facebook themselves: "You can use test users for manual or automated testing."
You can also pre-authorize test users with specific permissions to your app so there's no issue of getting stuck at the permissions dialog. In the FB response, you'll get a URL that allows you to login with that test user. With one or many of these URLs in hand, easy enough to use something like Seige or Apache Bench to automate your load testing of your Facebook App in its normal environment.