Facebook Canvas App Loading Partially - facebook

I have a single page FB Canvas app that is calling through the iframe a page I have hosted on Heroku.
Loading the page directly through my heroku link works no problem. However, when I try to load the page through the canvas app, it sometimes only loads half of the HTML. I need to spam refresh in order for the entire page to render correctly in the app.
I've checked my page against W3C validator and there are no syntax issues.
Is it Heroku just being slow? It loads pretty quickly when I access the url directly.
What could cause my page to just load halfway and stop?

I had this issue while using Heroku, but only for me and a colleague which were associated to the app as owner and tester respectively, other accounts could load the page just fine.
Testing the same app hosted via pagekite over a 24/3 ADSL works perfectly.
HTTPS or HTTP doesn't seem to matter. I'd say this is an Heroku issue.
EDIT: I'm not sure what happened, but the problem isn't there anymore. I can't think of anything that I did that fixed the issue, but I did many things both before and after the problem went away, such as cacheing remote data in the DB, and whatnot. I can't be certain anything of that helped or if it's some hidden issue in the Heroku infrastructure.
I contacted Heroku about the issue, by the time they came back to me, the issue had suddenly disappeared.
I have promised to get back with logs (both application and client HTTP/TCP logs), if you have this issue and can reproduce it, capture the logs and send it to Heroku support. Capturing TCP traffic can be done with wireshark and the Heroku application logs are available via heroku logs.

I had this issue, too. I think it is related to the issue in this question: iFrame showing up Blank in Facebook Canvas App
If it is a Python app using Flask try this code:
from werkzeug.wsgi import LimitedStream
class StreamConsumingMiddleware(object):
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
stream = LimitedStream(environ['wsgi.input'],
int(environ['CONTENT_LENGTH'] or 0))
environ['wsgi.input'] = stream
app_iter = self.app(environ, start_response)
try:
stream.exhaust()
for event in app_iter:
yield event
finally:
if hasattr(app_iter, 'close'):
app_iter.close()
Active it with this line:
app.wsgi_app = StreamConsumingMiddleware(app.wsgi_app)
Source: http://flask.pocoo.org/snippets/47/

Related

FlowRouter Reload Doesn't Route

I'm using FlowRouter. If I start on the homepage everything works well. I can work through the routes (change the pages) without problem. However, if I hit refresh in the browser, I get a series of errors. My url looks like this:
/story/586d536e34821281735b53a4
The ID is being returned in console under the following method:
Tracker.nonreactive(function(){
I think the subscription is being completed, so I'm a little confused as to why reloading a url is different than loading from the home page.
What am I not understanding here?
Reloading a url will make a HTTP request to server to get all the application source. Whereas navigating to a route from another one does not make any HTTP requests to get the application source because they are already available (they were loaded from the previous route), in this case the router will just get the appropriate content and render on the page. This is normal behaviour for Meteor apps and all other single-page apps
The error you encounter is because your data is not yet available on client, to fix it you could simple use a placeholder if the value is undefined.

Error in Facebook Connect with Devise on Rails

I have spent a few hours trying to debug this issue and while there are several answers I couldn't get this to work and don't understand a few things.
I have Facebook login implemented with Devise on my Rails 3 App deployed on Heroku. I have this working fine on localhost and I had this working on production as well. I don't think I changed anything but I found out that the Facebook login was broken and can't figure out how to fix this. A few clues that may ring a bell for some -
The url I am getting where the error shows is below with the error message that many others posts show. What I find strange is the following -
Decoding the url below the redirect_uri has a port number http://www.mygreenneighbor.com:24745/auth/facebook/callback&scope=email,offline_access&
I don't think the app on Heroku is listening at this port 24745 (which btw changes when I try it after sometime) and I haven't noticed that before - is that expected?
When I make changes to my Facebook app and change the site url that change doesn't show up in the redirect uri. Does it take time for FB changes to take effect?
https://graph.facebook.com/oauth/authorize?client_id=159903734070492&redirect_uri=http%3A%2F%2Fwww.mygreenneighbor.com%3A24745%2Fauth%2Ffacebook%2Fcallback&scope=email%2Coffline_access&response_type=code
{
"error": {
"message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.",
"type": "OAuthException",
"code": 191
}
}
Thanks for your thoughts/guidance.
-S
After a lot of digging around, I cam across this article
http://www.kbedell.com/2011/03/08/overriding-omniauth-callback-url-for-twitter-or-facebook-oath-processing/
I realized that I had switched to using Passenger as my web server from a singled threaded/process WebRick webserver. Passenger has more than one process running on the same dyno and apparently it sends a callback url with a port number in the request. To override that I used the advice in the above article and set the following in my applicaiton.rb file
OmniAuth.config.full_host = "http://www.mygreenneighbor.com" and it solved the problem.
Hope this helps someone.
-S

Windows Phone 8 facebook login (Beta)

I've been going through the instructions here trying to implement the FB login via the FB Beta application: http://facebooksdk.net/docs/phone/sso/
I had it working for a while, however ever since the last Beta update, something started failing.
Whenever i get a callback to MapUri from the FB application, i don't get the proper Uri being passed in. The following code always fails (the uri contains mundane URIs of pages within the application, not what i expected).
AppAuthenticationHelper.IsFacebookLoginResponse(uri)
I might have changes something on the web-configuration of the application, or on the WP8, however going over the settings, nothing seems to be working.
I checked the usual suspects (AppIds, ProductIds etc...) and it seems to be running properly, so that changing one of those IDs throws the error like i expect it to, however when i have setup everything properly, i get the facebook application to open my application, however the UriMapperBase when it get's called never has the proper Uri in it.
Here is the configuration for the WMAppManifest for the extension:
<Extensions>
<Protocol Name="msft-54045783c54e4c3a9f2b470c5b7ba353" NavUriFragment="encodedLaunchUri=%s" TaskID="_default" />
</Extensions>
Any ideas?
P.S. I am testing this on real devices with the latest FB Beta application.
UPDATE: Seems to only affect Samsung phones, no issues with HTC, haven't tried other ones.

FB.getLoginStatus not calling its callback

The title really says it all. Under some (undetermined) conditions FB.getLoginStatus() just stops working and won't invoke the callback I gave it. The only interesting clues I've found are
FB.Auth._loadState is stuck on "loading" -- whatever is supposed to make it click over to "loaded" isn't happening
slight delays like putting in alert() calls tend to make it start working
Any hints at all about even how to investigate this welcome.
This usually happens for me when I am running the page under a different domain from what has been registered in Facebook. Typically this is when I am developing locally.
If you are running locally, you'll have to set up a local web server and then modify your hosts file to point the the registered domain to 127.0.0.1 in order to test on your local machine. Don forget to remove that line from the hosts file when you want to test it on the server.
According to:
https://developers.facebook.com/bugs/240058389381072
You cannot put your application under sandbox mode, or else it won't work. Go into your app settings, advanced, and switch it. This stumped me for a couple hours until I happened upon the bug report.
I had similar problem with FB API. It turned out, that my Facebook App was misconfigured. Please make sure that this is not the case for you. My problem was that my "Site URL" param in FB application was pointing to https, but I was using http protocol for development. Any call against FB api after FB.init was not calling my callback functions. So the first thing to do should be to double check App config.
Now, if some reason you depend on FB api but you wish to have a fallback option in case it;s inoperative - workaround with timer should be ok for you. Just set up a timer and disable it if FB Api gives you proper response. If not - fallback to some custom function which will perform some additional logic.
function callFbApi() {
var timeoutHandler = setTimeout(function() { requestFailed(); }, 1000);
function requestFailed() {
// When this happens, it means that FB API was unresponsive
doSomeFallbackWork();
alert('hey, FB API does not work!');
}
FB.getLoginStatus(function(response) {
clearTimeout(timeoutHandler); // This will clear the timeout in case of proper FB call
doSomeUsualWorkAfterFbReplies();
return false;
}, true);
}
If your application is in sandbox mode, Facebook acts as if your application is invisible to anyone who is not listed as an application developer. If you're not logged in, then it would stand to reason that your app is now invisible.
The callback will only fire if you're initializing with a visible application. Otherwise the following response is returned:
<span>Application Error: There was a problem getting data for the application you requested. The application may not be valid, or there may be a temporary glitch. Please try again later. </span>
For more info please see my comment on this bug ticket:
https://developers.facebook.com/bugs/240058389381072
Maybe you are using the asynchronous call. The same thing happened when I called FB.init with window.fbAsyncInit. All I did was delay the FB.getLoginStatus with a setTimeout function
window.setTimeout(checkLogStatus, 1000);
function checkLogStatus(){
alert("check");
// fetch the status on load
FB.getLoginStatus(handleSessionResponse);
}
It seemed to work after that
On the new version of the Developer app, you have to make sure to have put the correct URL you are using to access the application in the Website field under the
Select how your app integrates with Facebook
section.
Make sure the protocol is HTTPS and not HTTP.
I had a similar problem. The site worked every time when I was opening the browser, but fails when I tried to reload.
The cause was the missing "www" on the site name on Facebook configurations. Note that putting "www" (like www.yoursite.com) works on both situations (yoursite.com or www.yoursite.com).
As others have posted, you must be accessing your site at the same URL that facebook expects. For example if facebook has a callback "example.com" but you're browser has "www.example.com", that can cause this problem.
In addition, if third-party cookies are not allowed by your browser, you may also see this problem. Or you may see the callback erroneously reporting the user is not connected.
Just posting a situation I had were calling FB.getLoginStatus got absolutely no response.
My application is designed to run in a tab, and I only entered the Page Tab URLs on the app admin page, and not the App On Facebook (i.e. Canvas) URLs. The tab loads perfectly, but any calls to the FB JS SDK provoke no response.
In Facebook App Settings, go to Client OAuth Settings, look at Valid OAuth redirect URIs
Make sure you have listed all URIs which are the domains from which Facebook SDK is being invoked. For example:
I develop at localhost:5000 and deploy to Heroku. Notice the format: http://domain.name/

Debug gwt inside facebook iframe

I'm trying to debug my gwt 2.0 apllication that runs inside facebook iframe.
When i use 'http://127.0.0.1:8888/index.html?gwt.codesvr=127.0.0.1:9997' as "Canvas Callback URL" my app doesn't loading, but when i compile it and use 'http://127.0.0.1:8888' it works perfectly.
There is a cross site scripting issue with using the GWT debugger within the facebook iframe.
I logged this as issue #4468
http://code.google.com/p/google-web-toolkit/issues/detail?id=4468
Within that ticket, I specified the workaround is to edit the hosted.html file thusly:
hosted.html
gwtOnLoad = function(errFn, modName, modBase){
....
var topWin = window.top;
var url = topWin.location.href;
...
Workaround if you have one:
var topWin = window;
var url = topWin.location.href;
I have a similar issue for deployment mode. Basically I want my GWT to be managed from a single entry point deployment and be able to run it as widget on 3'rd party websites, without them have to download my application into their host, only using the selector script as reference to my GWT app.
There is a problem doing that due to SOP limitation of current bootstrap process that uses an "iframe" to load the compiled script asynchronously.
I created a workaround procedure for that, let GWT app be installed using 'script' instead of 'iframe'. This makes my GWT available for 3'rd party websites, and let me maintain a single entry point of deployment.
The following article describe my workaround procedure:
Make GWT Widget Avialble For 3'rd party websites
127.0.0.1 is a reserved IP address that always resolves to localhost. So when you enter that as a Facebook canvas URL, Facebook tries to access it's own servers. A request never comes to your computer, which is where the application is actually hosted. Of course, when you access it at 127.0.0.1, it works fine, because your localhost is your own machine.
You need to figure out your external IP address, and enter that as the Canvas Callback URL. You can check your router settings, or go to something like http://www.whatismyip.com/. Once you have it, try accessing your application using it directly instead of 127.0.0.1. You might have to change your router or firewall to allow port 8888 through. Once you have it working, enter it as your Canvas Callback URL in your Facebook application settings.