Facebook IFrame APP using Asp.Net MVC - asp.net-mvc-2

I have been trying to work on a facebook IFrame app using Asp.NEt MVC and have not been that successful with it. Tried using the samples from facebook SDK however tags does not get recognized during development. Can some one share the code or point me to a working or preexisting facebook APP sample that would be of help. Thanks.

I abstracted away everything directly related to facebook in the Debug config my local machine. The Release config contains the facebook related stuff. I use Unity for DI, so I have DEBUG conditionals that configure different concrete implementations of interfaces.
#if DEBUG
LifetimeManager lifetimeManager = new ContainerControlledLifetimeManager();
container.RegisterType<ISteamRepository, MockSteamRepository>(lifetimeManager);
container.RegisterType<IFacebookContextSettings, MockFacebookContextSettings>();
#else
container.RegisterType<ISteamRepository, SteamRepository>();
container.RegisterType<IFacebookContextSettings, FacebookContextSettings>();
#endif
My project is open source, you can see more at http://code.google.com/p/facebooksteamachievements/

Related

Facebook is not initialized when using Facebook Login with React in Production

I love React, it has quickly become my favorite development tool. It is a fantastic library that creates the kind of flexibility I've always dreamed about.
That said, I'm having a very hard time getting Facebook login to work with React in production.
I have tried all of the following methods. In all three cases, I implemented the examples exactly as shown in the code using the simplest possible technique:
https://github.com/seeden/react-facebook
https://github.com/keppelen/react-facebook-login
http://jslancer.com/blog/2017/11/27/facebook-google-login-react/
Everything works great in development. :)
When I create the production build using create-react-app and push it live, it breaks and reports: Error: Facebook is not initialized or Uncaught TypeError: Cannot read property 'login' of undefined where undefined is FB.
Basically it seems like the Facebook javascript SDK is not loaded or initialized.
The first two links above are for existing component libraries, but the third is a custom implementation that places the Facebook initialization code in the index.html file and creates an event listener. The results are the same in all three examples.
It is as if something about the create-react-app compression method is obfuscating the variables to the point that Facebook can no longer work, or at least is not available to the react code. This includes all calls to window.FB as recommended in many tutorials.
I've been working at this for a couple of weeks now (off and on) and am now turning to the hive mind. Anyone have any ideas on how to get Facebook to actually work with Facebook's own code library (React)? It seems so painfully odd that it causes this much trouble and I have been unable to find a clear solution that works in production.
Most of the debugging steps are already mentioned in the comments section.
Here are the steps laid down:
1) Check the network tab in your browser's console and see if the request to load FB's SDK is successful or not
2) Most common culprit is some extension like Ad-Blocker blocking such async requests which loads JS on your web page. Disable it or try it incognito mode
3) Other common mistake I have seen is forgetting to use the FB.init({ // config }); function - which is the actual call which initializes the fb sdk and makes available the FB variable globally.

merge large existing web app into Sailjs site

I'm trying to merge large existing web app into sails.js. so I moved the folders into assets and build a custom route , 'GET /': '/assets/client/launch.html' and get 404 when I point my browser to http://localhost:1337/ as the / is correctly redirected to http://localhost:1337/assets/client/launch.html which produces the 404.
Now the file exists in the folder assets/client (and in .tmp), so I am thinking the Sails router is getting in the way.
I would leave the client (70K lines of JS) that generates all the UI dynamically and sailjs server that provides authentication separate and enable CORS but my customer wants client packaged with server. This type of operation is simple in frameworks like ASP.NET MVC but am wondering if Sails is up to the task.
Well, If everything you tried did not work out. There might be another solution ,
First of all since you are talking about sails app I am assuming other bundle must be sails as well ,
So here is what you do-
Change the port for another app that you want to attach to this.
Second whenever you want to go to page on another app simply redirect the client to another port ie
in html or esp put a href tag with different port.
<a href="localhost:PORT/route_to_file">
</a>
I got it working by placing my app into assets where we need to launch from assets/client/index.html as there would be too many dependencies to change. As I said above could not just add a route as Sails must getting in the way. However as in Chapter 3.2.2 of Sails in Action I generated a static asset npm install sails-generate-static --save. then I redirected to assets/client/index.html. As an aside that book is great and would highly recommend it.

Facebook page is not loading properly in mx:html (Adobe AIR) outside IDE

Adobe AIR application which was working perfectly earlier; is not working now. No idea whether it is due to any recent change in Facebook or Adobe AIR.
I have added the component mx:HTML to display http://facebook.com content. In the development environment (Flash Builder 4.5) after logging in facebook successfully; I can see the TimeLine contents and updates properly. But after build when executed outside the IDE; I am able to login facebook but the timeline or updates are not being displayed properly.
Anybody facing similar issue and has a fix; please provide the solution.
uncaughtScriptException gives following two errors...
TypeError: Result of expression 'bigPipe' [undefined] is not an object.
ReferenceError: Can't find variable: console
I have similar issue, if you catch the javascript errors you will notice that facebook is using some library that fails in AIR, then if you google that exact error you will find similar issues. My solution was to use the FB API and reimplement the functionality(in my case share) , other alternatives is to fix that library or FB code to make it work. I don't remember the details but I fixed it a week ago.
Check the docs for catching the JS errors uncaughtScriptException
I am wondering if that library has code for each browser that it supports and on AIR it fails, maybe changing useragent will help, you need to check the javascript code to see where it fails

First steps for migrating a Facebook Canvas App (untouched since Mar 2010) to OAuth and HTTPs --

I am not a professional programmer. I am "a kitchen table programming enthusiast." My question is at the very end of this narrative.
In March of 2010, I figured out how to introduce my interactive database driven web app to the world by turning my web app into a Facebook Canvas Application.
Basically I built my web app prior to March 2010 using MYSQL, PHP, HTML, JavaScript, etc. using "dummies" books. Once I was convinced that my web app was functional as a standalone website, I pored through Facebook online documents to figure out how to turn my app into a FB Canvas App.
That was in March of 2010. Back then the process for turning a web app into a FB Canvas App basically involved getting files like the following, and saving them to the directories on my web host server:
-- At public_html:
-- config.php
-- facebook_desktop.php
-- facebook_mobile.php
-- facebookapi_php5_restlib.php
-- fbtest.htm
-- JSON.php
-- jsonwrapper_inner.php
-- xd_receiver.htm
-- At public_html/php:
-- facebook.php
Now here is my question:
My app has been working fine since March 2010, but now (since this morning) my app doesn't work at all (doesn't even open). I suspect this is due to requirements that changed related to migration to OAuth 2.0 and HTTPS -- requirements which I need to learn how to respond to.
What should be my first step toward at least enabling myself to continue using my own app on FB? Once we have figured that out, I will be seeking guidance on how to once again enable other FB members to use my app.
I hope some will find this thread helpful.
Thank You,
FL
There's an overview here: https://developers.facebook.com/docs/oauth2-https-migration/ which links to the docs and the blog posts which gave examples of how to migrate
Thank you, so much!
I have begun reviewing the material you have referred. I will continue to dig in, but I'd like to let you know that for now, I see these phrases which raise questions in my mind:
-- "If you are only using the PHP SDK (Software Development Kit) for authentication..."
-- "If you are using the JavaScript SDK for login..."
-- "Update to PHP SDK..."
-- "Update to JavaScript SDK..."
-- "Implementing the OAuth 2.0 authentication system..."
-- "Using the latest SDKs..."
Based on details in my original post is one able to determine whether I have currently implemented a PHP SDK or the JavaScript SDK? I don't know that I ever even used an SDK for establishing my means for Authentication and Authorization. I only knew my method as applying for a FB App ID, App Secret and copying a set of files to my server. Was my implementation method from March 2010 so old that it is neither PHP SDK nor JavaScript SDK?
Doesn't "updating an SDK" require that I had first implemented some sort of SDK?
If it turns out that I haven't used an SDK as part of my archaic means for authentication and authorization then what set of instructions is really applicable for me to migrate to OAuth2.0?
I am concerned that without seeing a step by step set of instructions, I will end up with extraneous and conflicting files on my server.
Does anyone know of any migration instructions like, "replace these files (file A, file B, file C and file D) from your web host server with these files (file E, file F, file G and file H)"
Thank you,
FL.

Deploying MVC2 application to IIS7.5 - Ninject asked to provide controllers for content files

I have an application that started life as an MVC (1.0) app in Visual Studio 2008 Sp1 with a bunch of Silverlight 3 projects as part of the site. Nothing fancy at all. Using Ninject for dependency injection (first version 2 beta, now the released version 2 with the MVC extensions).
With the release of .Net 4.0, VS2010, MVC2 etc., we decided to move the application to the newest platform. The conversion wizard in VS2010 apparently took care of everything, with one exception - it didn't change references to mvc1 to now point to mvc2, so I had to do that manually. Of course, this makes me think about other MVC2 things that could be missing from my app, that would be there if I did File -> New Project... But that is not the focus of this question.
When I deploy this application to the IIS 7.5 server (running on Win2008 R2 x64), the application as such works. However, images, scripts and other static content doesn't seem to exist. Of course they are there on disk on the server, but they don't show up in the client web browser.
I am fairly new to IIS, so the only trick I knew is to try to open the web page in a browser on the server, as that could give me more information. And here, finally, we meet our enemy. If I try to go directly to the URL of one of the images (http://server/Content/someimage.jpg for instance), I get the following error in the browser:
The IControllerFactory 'Ninject.Web.Mvc.NinjectControllerFactory' did not return a controller for a controller named 'Content'.
Aha. The web server tries to feed this request to MVC, who with its' default routing setup assumes Content to be a controller, and fails.
How can I get it to treat Content/ and Scripts/ (among others) as non-controllers and just pass through the static content? This of course works with Cassini on my developer machine, but as soon as I deploy, this problem hits.
I am using the last version of Ninject MVC 2 where the IoC tool should pass missing controllers to the base controller factory, but this has apparently not helped. I have also tried to add ignore routes for Content etc., but this apparently has no effect either. I am not even sure I am addressing the problem on the right level.
Does anyone know where to look to get this app going? I have full control of the web server so I can more or less do whatever I want to it, as long as it starts working.
Thanks!
I had a similar problem with StructureMap and favorite.ico what I ended up doing was to add a route to ignore that path.
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("favicon.ico");
Keep in mind that I have absolutely no idea really but another thing that changed is the need for Default.aspx, also if you have any custom pages those would need to mapped. That's the only two problems I had with routing.
routes.RouteExistingFiles = false;
EDIT: I meant that the RouteExistingFiles should be false otherwise I get that exception in MVC2 :)
Turns out this was caused by some account settings - I was unaware of the IIS AppPool\sitename account automatically being created by IIS in Win2008 R2 server. After trying "everything", I came across this information, gave the proper rights, and stuff magically started working.
Pretty hard thing to debug, especially for someone (me) with very limited IIS experience.