Blank Screen with Mobile Web App with Facebook Connect [duplicate] - iphone

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
blank white screen after FB login via web app?
I am building a web app that can open full-screen on iPhone and am following the code for Facebook mobile web, which can be found at: https://developers.facebook.com/docs/guides/mobile/web/
When I try to login using the Facebook login page, I get a blank white screen after I click the "login" button. The user IS logged in though.. I know this because if I close and reopen the web app, I check the login status and try to get some user info, and it works fine.
I have seen others with the same here: blank white screen after FB login via web app?
It seems that somebody has identified a workaround, but I cannot get it to work. The code I am using is:
function loginUser() {
FB.login(function(response) { }, {scope:'email'});
}
Others have indicated that I need to utilize the workaround here:
login({scope:'email', redirect_uri:'where_to_go_when_login_ends'})
Does anyone know how to merge these pieces of code to get it to work?
Thanks!

This should work:
function loginUser(){
FB.login(function(response) { }, {scope:'email', redirect_uri:'http://your-redirect-url'});
}

Related

Blank screen with Mobile Web App and Facebook Connect

I am building a web app that can open full-screen on iPhone and am following the code for Facebook mobile web, which can be found at: https://developers.facebook.com/docs/guides/mobile/web/
When I try to login using the Facebook login page, I get a blank white screen after I click the "login" button. The user IS logged in though.. I know this because if I close and reopen the web app, I check the login status and try to get some user info, and it works fine.
I have seen others with the same here: blank white screen after FB login via web app?
It seems that somebody has identified a workaround, but I cannot get it to work. The code I am using is:
function loginUser() {
FB.login(function(response) { }, {scope:'email'});
}
Others have indicated that I need to utilize the workaround here:
login({scope:'email', redirect_uri:'where_to_go_when_login_ends'})
Does anyone know how to merge these pieces of code to get it to work?
Thanks!
The problem lies in the fact that the login window normally opens as a pop-up window. However, in (iOS) web apps this is not properly supported for some reason.
By providing a normal link instead of FB's own login btn script, the login process stays within the same window (including the redirect process!)
I hope this helps anyone...
LOGIN!
Try this, it worked for me :
FB.login(function(response) {
//deal with response
}, {scope:'permissions', redirect_uri:'url to redirect to'} );

How do I get back to the iPhone web app after having logged in with Facebook Connect?

I have a mobile web site built using jQuery Mobile. I often run it in full screen/mobile web app mode on my iPhone (I have added the web app to my iPhone home screen).
On one of the pages, the user is required to log in to Facebook using the Facebook Connect JavaScript API. If the user is not already logged in, this is done by clicking a login button. The event handler for this button looks like this:
("#fbLogin").click(function () {
FB.login(handleStatusChange(response),
{ scope: "publish_stream",
connect_display: "touch" });
});
In the above code I have inserted some line breaks for better readability, but the values are like in the example. The callback function (handleStatusChange) takes care of the response from the login request.
When I click this, the Facebook login page is opened in my web app window. If I haven't already accepted the Facebook App, I have to give it permissions as well. All this seems to work fine. But after I have given permissions/logged in I'm left hanging on a totally blank screen.
I have also tried another approach to logging in, by putting this inside the login button event handler:
window.location = "https://www.facebook.com/login.php
?api_key=MY_API_KEY
&cancel_url=http%3A%2F%2Fwww.mywebsiteurl.com%3A8081
&fbconnect=1
&next=http%3A%2F%2Fwww.mywebsiteurl.com%3A8081
&return_session=1
&session_version=3
&v=1.0
&req_perms=publish_stream
&connect_display=touch";
Again, line breaks have been inserted for better readability. When used it's just one long string.
The URL used in the cancel_url and next parameters is the one I have registered with the Facebook Application. If I try using a different URL (like http://www.google.com) I get an error so the this seems to be correct. As you can see I use a different port on my development server (port 8081). Could this be a problem?
The result is similar to the previous example. I get the login/permissions pages but I'm left with a blank screen after everything is done. I tried this after reading this post on the old Facebook Developer forum.
If I, on the other hand, try running this in Safari (not as a full page iPhone web app) the login works great.
Is there anything else I can try? Does anyone have a JavaScript API Facebook Connect login working while running in full screen/web app mode on an iPhone?
Thanks in advance!
Not sure if this helps you, but I found that adding the iOS Safari link fix, also allowed Facebook login to work in my fullscreen web app without opening up the page i "regular" Safari:
// Make links work in iOS fullscreen web app
function disableSafariLinks() {
$("a").click(function (event) {
event.preventDefault();
window.location = $(this).attr("href");
});
}
See also iPhone Safari Web App opens links in new window

Knowing if a page is already liked on facebook [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to know if the user already like the page in Facebook Likebox?
Is there a way to know if a user likes the current page WITHOUT using asking the user for permissions?
The page has a like button and I am using the javascript to figure out when this button is clicked to show hidden content. However when the page is refreshed the button is shown as "liked" but the hidden content is still hidden.
Is there a javascript to know if the state of the facebook button is "Liked"?
Is there a javascript to know if the state of the Facebook button is
"Liked" without app authorization/authentication on my web page (not FB page tab)?
NO, this is not possible.

Facebook Share not working while logged in with Facebook Connect

I have a Drupal 6 website where I've implemented Facebook Connect with the JavaScript SDK and it's been working fine for some months.
The site used the old Facebook Share button (pointing to sharer.php) but that didn't work with the new Facebook Connect API so I replaced it with fb:share-button.
My problem is that the Facebook share button doesn't work for users logged in via Facebook Connect. The lightbox for Facebook Share appears empty with just the loading bars. If the user is logged in to the site as a non Facebook Connect user then Facebook share works normally.
I've searched for similar problems and found an unanswered post at Facebook developer forum that looks like a similar problem.
This site also uses Facebook Like buttons but those, as far as I know, don't allow including an image from the liked image like share does. The owner of the site needs Facebook Share and has no plans of removing it to work just with Facebook like.
Any suggestions?
Thanks.
I got this code working for sharing
function share(){
var share = {
method: 'stream.share',
u: document.getElementById('txtShare').value
};
FB.ui(share, function(response) { console.log(response); });
}

facebook login page in lightbox [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Facebook page acquire full screen after clicking on iframe
I want to open facebook login page in a lightbox.
if i tried to open facebook page in iframe then after loading successfully , in case a user click on an iframe , facebook will cover the whole page.
But i want to open it in lightbox
Please do not re-post your question multiple times.
Facebook page acquire full screen after clicking on iframe