facebook apps redirect to hosting url in the first usage - facebook

I built a facebook apps from an tutorial with using adobe flash builder 4.5 . It is hosted on heroku.
This app gets name, image, birthday and status message . It displays these infos in the screen. And you can also post status message to your fb account. As you understand, it is very simple apps.
In the first usage of this app, after permission dialog, url is redirected to hosting url.
When you want to use it again, You can use it on facebook.com
do you have any idea why it is redirected to hosting url in the first usage after permission dialogs.
Thanks,
cergun

Selam Ceyhun,
This is expected behavior, what you can do for this is simply:
<script type='text/javascript'>
if (window.top.location == window.location)
window.top.location = 'https://apps.facebook.com/myapp';
</script>
that's it.

Related

Facebook canvas app with rails3

I'm writing facebook canvas application with Rails3 using omniauth-facebook gem. The few moments are not clear:
Rdirect after sing in (in '/auth/facebook/callback' => 'session#create'):
After successful sing_in if user is redirected to root_url it sometime arrives to
my canvas page URL (http://localhost:3000) outside of the frame. On other hand, when
redirecting him to my app url (http://apps.facebook.com/my_app) it sometime stacks on
blank page inside the frame. So how to handle this redirect correctly?
What is a proper way to link between pages inside my app? Currently I use relative links and top.location url is always stay my app url (http://apps.facebook.com/my_app). But I saw that many facebook apps redirect the client top.location (http://apps.facebook.com/my_app/internal_link)... It raises one more question:
Now facebook always fetch my app into the iframe using POST method. How to handle this behavior in RESTful rails application?
I'd very thankful for any advices...

Facebook mobile web returns 'Your link could not be found' when sharing a URL

When users try to share a URL on facebook mobile web, sometimes the page returns the following message: 'Your link could not be found' and a text input to manually insert the URL
Sharing URL that works:
https://m.facebook.com/sharer.php?u=http://dishenvy.com/dish/pollo-garnachas-gran-electrica-brooklyn
Sharing URL that doesn't work:
https://m.facebook.com/sharer.php?u=http://dishenvy.com/dish/samgyupsal-hahm-ji-bach-new-york-
Code I'm using:
<a class="fb_share" name="fb_share" type="icon" share_url="<?php echo urldecode($shareUrl) ?>">
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
Make sure the url you pass is accessible to Facebook. Not sure why, but their mobile site seems to validate the url but their non-mobile site does not seem to care. If you have code generating the link you pass to facebook and the host corresponds to a server behind a firewall or private network (such as a test or dev server), this error will often happen.
According to the debugger the two url example that you posted work the same:
First
Second
So I don't know how to help you with that.
What I can tell you though is that you are using a deprecated api.
The facebook "sharer" is no longer supported as it states here:
The Share button has been deprecated in favor of the Like button, and
will no longer be supported. Please use the Like button whenever
possible to drive maximum traffic to your apps.
And here:
What happened to the old Share button?
We deprecated the Share Button when we launched the Like button,
because the Like button improves clickthrough rates by allowing users
to connect with one click, and by allowing them to see which of their
friends have already connected.
That may be a cause for the inconsistency you are experiencing.
My advise to you is to stop using this deprecated api and move to the Like button.
I think facebook check your sharing page found or not on the server. Your first url found on the server (It means first url return the page). Second url doesn't return the page. The second url return the empty page for this reason facebook return this message. 'Your link could not be found'
Click the link :
http://dishenvy.com/dish/pollo-garnachas-gran-electrica-brooklyn = Page found
http://dishenvy.com/dish/samgyupsal-hahm-ji-bach-new-york- = Page not found
So share correct url on the facebook
https://m.facebook.com/sharer.php?m2w&u=http://dishenvy.com/dish/samgyupsal-hahm-ji-bach-new-york-
For mobile view you want to add m2w to the url.

How to redirect the user to the log in page in a Facebook App

I am hosting a Facebook app on Google app engine, I need to make sure the user is logged into facebook before anything.
What I can currently do is display facebook's log in button using fbxml, but I prefer the user would be redirected to Facebook's log in page if he wasn't logged in, then back to my app's main page, this way I can make sure that the user is logged in before doing anything.
I am new to Facebook apps, I read here that I can redirect the user to
https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL
in order to authenticate him. But using GAE's self.redirect(url) doesn't work, the page stays the same. I was hoping I could do something like this in my handler:
if u'signed_request' in self.request.POST:
facebook.load_signed_request(self.request.get('signed_request'))
if not facebook.user_id:
self.redirect("https://www.facebook.com/dialog/oauth?"+
"client_id={0}&redirect_uri={1}"
.format(FACEBOOK_APP_ID, EXTERNAL_HREF))
return
but as i said earlier this doesn't work.
I'm assuming by 'Facebook App' you mean a Canvas App - so something that will live at https://apps.facebook.com/YOUR_NAMESPACE from a user perspective?
If so, you'll need to add the redirect via Javascript using window.top, as your app is loaded in an iframe. See https://developers.facebook.com/docs/appsonfacebook/tutorial/ and search for 'top', then view the example toward the end of the page.
There are also good examples on the Php Sdk that facebook provides. I like the with_js_sdk.php example. It runs seamlessly and is good to follow.
https://github.com/facebook/php-sdk
http://developers.facebook.com/docs/reference/php/

How to redirect to application page after installing application to one's page or app?

Now I want to automatic redirect to facebook application's index page after user installing the application to his/her facebook page.
My method is use the href tag as below:
<a href='http://www.facebook.com/add.php?api_key=".$APPID."&pages&perms=publish_stream&page=".$paID."' target='_top'>Add APP</a>
I have tried some ways such as add redirect_uri or next or post_authorize_redirect_url as parameter to the add.php link,but they all redirected to the facebook page or application after installing.
Then how to realize it?
Useful link
http://developers.facebook.com/docs/authentication/
I know that it can redirect after authentication.Such as:
https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=https://www.facebook.com/connect/login_success.html&response_type=token
But what is after installing?
You could just use the API to add the app to the page?
https://developers.facebook.com/docs/reference/api/page/#tabs
https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL
Client ID is your app id
Redirect uri is your callback page
For more you can look at this page

How to authenticate multiple entry points in a facebook app?

I am using an IFrame application with XFBML and the new Javascript API.
I'd like to have a facebook application with multiple entry points. These will most likely represent different links coming from a fan page tab.
I can do this quite easily if the pages don't require authentication - for instance I can create several pages under the app and if a new user comes I can send them to any page:
http://apps.facebook.com/myapp/offers
http://apps.facebook.com/myapp/game
http://apps.facebook.com/myapp/products
The problem is that if I need to have authentication then once the user is authenticated they get redirected to my default post-authorization url.
Is there a way for a user that comes to /game to stay on /game after they are authenticated without redirecting.
I thought I could do it with the AJAX login form - but I cannot find out how to do that in a Facebook IFrame application.
I think the example using requirelogin only works for FBML.
<a href="http://apps.facebook.com/mysmiley" requirelogin=1> Welcome to my app</a>.
Is there a way to accomplish this with Facebook APIs - or will I have to do some kind of clever cookie handling?
You can use the facebook connect JS library inside of an iframe app and then redirect them to the appropriate url in javascript if they click allow. Best to go to the Facebook dev docs on the Javascript SDK on Fb:login here: http://developers.facebook.com/docs/reference/javascript/
Basically if the login is successful, you will get a callback where you should redirect them in javascript by using window.top.location = 'yoururlhere';