Permission on facebook fan page - ruby-on-rails

I am a newbie with facebook applications.
Ok. I should create a fanpage. This should connect to my Rails application.
So If user is a fan I should show "fan page 1", else i should show "fan page 2".
How could ask permissions on facebook fan page?
Thanks in advance and excuse if you don´t understand my question.

You have a couple of options.
The easy one is to use on of the FB apps like Static HTML Tab that lets you put in some HTML (usually an iframe) for the fan, and another for the non fan. Here ar some of the apps:
Static HTML App
http://www.facebook.com/apps/application.php?id=190322544333196
Or a round up (some paid)
http://www.socialmediaexaminer.com/top-10-facebook-apps-for-building-custom-pages-tabs/
Then your second option is to develop it your self. It is not that hard.
In your App Settings there is a field fot your TAB URL. Point that to a file you would like to use as a tab somewhere in the directory of your app. in PHP you_domain.com/app/tab.php
When Facebook loads that URL in a tab it will pass it a signed request that contains basic information about the user Liker or not, Locale etc.
You can extract that data and depending on that information show one piece of content or the other.
Here is a post on how toparse the signed request with rails:
http://qugstart.com/blog/ruby-and-rails/facebook-base64-url-decode-for-signed_request/

Related

Open web page and bypass login from iPhone - iOS

I want to open, from an iOS app, a web page that requires authentication in order to get to that page.
I googled a little bit and I believe I need to use WebKit and Javascript injection, but I am not sure and I have never done something like this, so every bit of information is welcomed or pointing me in the right direction.
I will give an example that I hope will make things more clear(I don't actually want to open facebook, it's just part of the example):
Is it possible to do the following scenario? And if yes, how?
Open a web page from an iOS app, for example: "https://www.facebook.com/profile" without having to go through the login page? I do have the user credentials(username and password), as the user is already logged in with those credentials in the iOS app, but the requirement is to not go through the login page, but to go straight to the profile page.
In general the answer is: no. Even if the user is already logged in and has a valid authentication token that token may only be valid from within your app and not from within the browser. And the login form may be protected by something like a captche preventing you from automatically logging someone in.
There certainly are situation where it is possible: For example if the tokens are not scoped to your app you can try passing them along. Or there is an actual API that you can call with the token that logs the user into the website on the website, etc. But those depend on the specific target website or wether you can control that target website and can add this functionality.

How to make posts from like button public by default?

I have an unusual problem with my website, which has been built using Ruby on Rails technology. Whenever I click "Like" button under any post on my webpage, the post is supposed to be shared on my facebook profile like posts from 9gag. The problem is that by default, this post's visibility on my facebook profile is set that only I can see it and I want the post to be (by default) visible for all my friends. How can I do that? I couldn't find anything helpful on google about this case.
Thanks for help in advance!
I had the same problem with my website. For some reason, the Facebook App that you create to add widgets to your website sets its privacy default in your profile to "only me".
This only happens for the user that creates the App (maybe to avoid making your first tests and debug public) : in fact, I noticed that other users can share articles publicly without changing any settings.
To change it, just go to privacy settings in your Facebook profile: there you will see your website preference under Applications. Change it from "Only me" to "friends" or "public"

RoR Facebook Canvas App user Registraton & Login

I'm currently working on a RoR app that is only going to be used inside the Facebook Canvas. To model the users I use Devise. Now, I'm aiming at making the signup & login process easy as pie. If my prospective users open the app, he/she should be prompted to authorize the app to access name and email. If this happens a user should be created with the name, fb_uid and email. Every time this user now comes back to the canvas app he should be signed in.
How do I accomlish this?
Please help - looked at koala, omniauth, the javascript and php sdks -> my brain just feels fried...
This railscasts episode shows you how to easily put together the authentication system using omniauth-facebook. I actually just used it today as well. Let me know if you have any more specific questions.
http://railscasts.com/episodes/360-facebook-authentication

Facebook Likes on pages within a page tab app

I'm building a page tab app on Facebook that allows users to create and display their own entries, and I want to be able to have a share and a like button specific to each entry.
I'm using the app_data parameter to pass the path to the page within the app, and it works perfectly with the share button - a user can share their entry to their wall, and that share links back to the appropriate page.
However, when I try to do the same thing with Likes, it instead shows the total likes for the page the page tab is a child of. Has anyone had a similar problem or could point me in the right direction to sorting it out?
Cheers!
You can’t like specific page tab contents – Facebook will count all likes for the Facebook page, no matter what app ID and possibly app_data the URL contains.
You could however like your own URLs that are loaded inside the page tab frame – and have them redirect to themselves embedded into the iframe with JavaScript if a real user is visiting them.

Inviting *all* your friends to the Facebook Application

At the moment, using the requests dialogue I can get a multi-friend selector come up when I want the user to invite their friends to my application (that's when the "to" parameter isn't defined). On Chrome / Safari - this is a new window, but is there any way of having all of the users friends already selected?
Otherwise - is there a way to put together a request / invite to all of the users friends? I've tried getting an array of all the user's friends id's into the "to" parameter, but that gives an error on FB.
I've seen a few applications on facebook that do make it possible for the user to "select all" or "invite all" of their friends - http://blog.fbsocialapps.com/2011/10/5-ways-to-tune-your-requests-to-improve-the-virality-of-your-facebook-application/
Edit - As mentioned in the comments, I'm doing this on RoR using the omniauth gem + JS SDK. I was hoping that someone may have come across this problem, and can share a solution. My intentions are not to spam, but make it easier for the user to share the application if it's worth sharing.
Basically what the apps mentioned on the site you posted are doing is to use a custom friend selector (See also: Requests Pro-Tips, Pro-Tip 2: Create a Custom Multi-Friend Selector).
This is pretty easy and straight-forward – read the list of the users friends, generate the kind of HTML you’d like them to be displayed with (a Form, an UL, IMG elements with the friends profile picture, Checkboxes to select friends, …). If you don’t want to use the JS SDK, you can do that (reading friends list + generate the HTML) server-side as well in your RoR app.
Only the part where the user can select all friends at once is probably best done client-side – loop through all the HTML elements representing the listed friends, and check the checkboxes via script. Pretty easy if you are for example using jQuery or something.
(Of course this could also be done by just having a checkbox labeled “send request to all friends”, and see if this is checked server-side and then send request to all friends – but that would not provide direct feedback that all friends are selected now to the user on the page.)
Then you could just send the form with all/some friends marked in it to your server-side app, generate the URL for the request dialog there and put the friend’s ids into the toparameter, and redirect the user’s browser to it.

Resources