Already posted this on Unity Forum and Unity Answers, but either support there moves too slowly or it's not been encountered. Thought I'd post to SO as well
I've been trying to update our current Unity project to use the new Facebook SDK for Unity and all the lovely features that come with. Up until now all we've had is a server-side implementation to request permissions using the PHP SDK. We held off on further implementation as we knew the new SDK was going to be released imminently.
However, now that we're implementing it, we've run into a slight problem getting it to fit with our current process. Now that Facebook Apps can link directly to a deployed .unity3d file, the PHP page that the web player used to sit in no longer gets hit and as a result, none of the PHP code is executed. We used the server-side code and PHP SDK to do the account creation for new users but because this is no longer being hit, new accounts are no longer created.
In the settings for the Facebook SDK for Unity asset, it actually has a tick box for "Cookie" with a description that implies usage in server-side code... but I have no idea how I'm supposed to access this cookie when the web page specified as the Facebook App's (Secure) Canvas URL is never hit... not even once.
I've searched around and can't find anyone else with a similar problem, so either I'm doing something wrong or it's not been encountered? Hopefully it's something simple and I'm just being daft
Anyone know how to solve this?
Thanks!
You can pull your server-side account creation into an async call. After calling FB.Login(), take the FB.UserId in the callback when you get it and pass it to your backend to check if they have an account. create one if they don't.
I don't think you need the cookie support, but if you do, it follows the same as the Javascript SDK, so you should be able to use ExternalEval() and Javascript to get at the data.
Related
I am not sure if the title of my post is right, spare me if it is wrong :)
I am using the latest facebook sdk with unity (Ver 4.2). When i call a fb.api request, i get the message "Nearby" whenever some facebook stuff is loading.
Scenario.
A share on fb/ connect with fb/ invite friends function, loads facebook.
At this point, there is a waiting dialog. Weirdly enough this waiting shows "Nearby" rather than waiting/loading. And i could not find any option to configure this.
I looked high and low, but could not find a place where i could configure the default waiting message. Any suggestions?
You can modify Unity/Assets/Plugin/Android/res/value/strings.xml - modify <string name="com_facebook_nearby">nearby</string> entity. But I think it is not a solution. I guess that there is some kind of logic with place picking in the Unity Facebook SDK while login flow. But unfortunately I have not figure out it yet
I want to use Facebook's PHP SDK to create/update/cancel events on our Facebook Page, whenever they are added/modified/deleted within the "calendar of events" database table on our web site.
Where do I even begin with this? I have the SDK installed, but I am having a really hard time figuring out how to register my own custom app and install it to my Facebook user account. I did manage to get an App ID and App Secret, and I also created a minimal canvas and indicated which persmissions the app needs. But, for the life of me I can't figure out how to install the app on my FB user account.
I don't want to make the app available to others, and I don't even want to access it while I'm logged into Facebook. I just want to be able to do something like $fbapi->createEvent() within my own code on my own site.
Also, do I need to have an authenticated Facebook user session/cookie when calling the API to create the event? It seems to me that would eliminate the possibility of creating events via a command-line PHP cron job.
I feel like I am understanding bits and pieces of this, but there are gaps in my understanding and I'm not seeing how all the pieces fit together. Any direction would be immensely appreciated!
First play around with the Graph API Explorer https://developers.facebook.com/tools/explorer so you can understand better how the Graph is used. From there you can then learn about the PHP SDK http://developers.facebook.com/docs/reference/php and how to do the same things you did with the explorer tool. Events are here documented here: http://developers.facebook.com/docs/reference/api/event/
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.
I just got this email from Facebook:
Dear Developer,
As part of our continued efforts to migrate all apps to OAuth 2.0, we
opted in all apps using the new JavaScript SDK to OAuth 2.0 this
afternoon at 11am PT and reverted at 1:30pm because we noticed that
your app has not migrated. Please ensure that you have set the oauth
param in FB.init to true and that you are using FB.getAuthResponse to
obtain the access token.
Read more in the OAuth2 migration announcement, updates to the new JS
SDK blog post, or our JS SDK docs.
If your app was affected today, please ensure that you have made these
changes by December 13th, 2012 to avoid any disruption with your
users.
The email doesn't specify which app needs my attention, and I can't make heads or tails of it.
Can anyone tell me what I need to be doing here? I have seven apps:
Four were created solely because I needed an app ID (API key) to install the "Like" button on various sites. Do I need to add "oauth: true" to the FB.init() call on these pages? (None of them actually integrate with Facebook authentication. All they do is render Like/Send buttons, and hook into the Edge.create callback for tracking purposes.)
Two of my apps are just tabs that I've added to Facebook Pages, which pull in static HTML pages (hosted elsewhere) via iframe. There's no JavaScript or server-side code whatsoever. I presume I can leave these alone?
One is an off-the-shelf app from a third-party provider. Looking at their code, I see that their call to FB.init() already includes oauth: true.
Facebook does a really terrible job with developer documentation, explaining changes, and maintaining backward compatibility. I'm a pretty experienced developer, but it seems like you have to learn every nook and cranny of Facebook's (ever-changing and over-complicated) proprietary API suite just to use the simplest features. I'm not a Facebook app developer (and I don't want to become one); I'm just a guy who wants to use a few "Like" buttons and custom page tabs, preferably without having to wade through this nonsense every two months when Facebook decides to change everything around and break backward compatibility again.
Anyway, any guidance would be much appreciated!
If you didn't see any of the blog posts since May - here's a summary: https://developers.facebook.com/docs/oauth2-https-migration/
To answer your specific questions, the 4 apps used only for the social plugins don't really USE oauth - but adding the oauth:true param and making sure they still work shouldn't be a huge issue - it also explicitly indicates to facebook that you're using the new auth mechanisms on those app IDs, so you shouldn't have an email sent about those apps in future
If your other apps aren't actually using any authentication, you probably don't need to do anything - if there was a problem you'd have discovered it yesterday when the oauth migration was flipped on for apps - the non compliant apps would have ceased working correctly
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!