Facebook integration for "desktop" applications

Hi guys, I’m trying to integrate Facebook into my game which will be Windows/Mac based (not web). I’ve got the library loaded and I can make unauthorized calls through Unity:

		FacebookAPI api = new FacebookAPI(token);
		Facebook.JSONObject me = api.Get("/4");
		Debug.LogWarning(me.Dictionary["name"].String);

and all works as expected, however, to make the game more interesting I want the user to login so I can access more information (their friends, etc) and, as per the Facebook API, this requires you to grab an OAuth access token. You obtain this token by redirecting the user to a page, they login and they get redirected to a “success” page with the OAuth token in the URI. My question is how can I get this URI? The Unity WWW lib doesn’t seem to be versatile enough and I have no control over Application.OpenURL to see what was returned. Has anybody tackled this problem at all?

Thanks, Paul :slight_smile:

You must use an oauth library to facilitate this.
there are some for .net which you can use for that.

without oauth login you won’t get anything to use to login to facebook etc.

good thing is once you done that you can use that to integrate twitter too for example as they also use oauth authorization

Hi dreamora, that’s fine for actually /doing/ the authorisation but it still requires me to pop up a browser/window and ask the user to login to Facebook and give permission for my game - that’s the bit I’m struggling on. I can’t use the WWW class because it requires user intervention and by using Application.OpenURL I have no way to get what was returned…

Regards, Paul.

bump anyone? :expressionless:

Well I managed to get it working and I’ve created a blog post over at: http://www.ifc0nfig.com/accessing-facebook-within-unity/

I’ve included source code and a small explanation so hopefully it will help others :slight_smile:

That was exactly what I was looking for.
Thanks a lot!!!