invite facebook friends to application without a popup rails - ruby-on-rails

I'm making a simple application to practice learning rails and web development in general.
What I'd like to do is list facebook friends so that I can invite those that don't have the app to come use it with me.
Currently I'm following a tutorial which pops up the friends on facebook I can send the application to. However I'd like to remove the popup option and simply display on the page the facebook friends invitation list (i.e. checkbox, name, picture). How would I go about doing that?
Here is my code of Home.html.erb. Please let me know if you have any suggestions. Thanks!
<div id="friends">
#instead of the below link which creates the pop up, I'd like the page to
#simply display the facebook friends to invite
<p><%= link_to "Invite your Facebook Friends","#",:id=>"invite_fb_friends"%></p>
<div id="fb-root"></div>
<script src ="http://connect.facebook.net/en_US/all.js"></script>
<script>
$(function(){
$("a#invite_fb_friends").click(function(){
FB.init({
appId:'1234567890', #<--fake appid, my code includes the my actual app id
cookie:false,
status:true
});
FB.ui({method:'apprequests',message:'<%=current_user.name%> would like to invite you to try out our app!'});
});
});
</script>
</div>

You can get a user's friends info (provided you have the permissions in the access token) via:
https://graph.facebook.com/:facebook_user_id/friends?access_token=token
You'll receive a json response of the user's friends. Simple parse the JSON code, and from their create a list of friends in the view. Use check boxes or something, compile each ID they select, and create a request
To see what the data looks like, goto: https://developers.facebook.com/tools/explorer
and put in /me/friends

Related

Twitter tweet contact widget

Is there a twitter widget to let users on a website tweet at you from a form field on a webpage?
I'm wondering if I could replace a contact form with just a text area field that lets users tweet to my account if users have a twitter account and are logged in.
I don't see any widgets on Twitter website that allow this:
https://dev.twitter.com/web/overview
Apologies if this is not the right forum to post this question.
Thanks!
Jon
You can't present the text field on your site unless you first take the user through the authentication flow to get an access token. For a simple "contact me" situation, it's unlikely many users will want to allow your site to tweet on their behalf.
You can use the Tweet button to popup the Twitter interface with a pre-populated mention using a URL like this:
https://twitter.com/intent/tweet?text=#username

Post to named Facebook page?

I can currently read the newsfeed from http://facebook.com/RelayForLife, however I don't know how to post to this page (or other similar named pages that allow posting) as the logged in user. All examples I see out there are for posting to the user's page or an app page.
Obviously, I can't use the built-in SLComposeViewController to accomplish this.
you can only post to facebook page if user (Profile posting), using graph api and facebooksdk. You need to get user first to like that page then you can post to that page

Rails - Twitter API: how to get from ID link to Twitter profile?

From the Twitter API I obtain user's ID (of course beside profile link, username etc). How can I display the link to user's profile according his ID?
For example, Facebook API provide user's ID as well, and if I put to the browser www.facebook.com/users_id, I'll get his profile...
Is there any way to do with Twitter? www.twitter.com/users_id returns empty page...
EDIT: obviously I can save user's URL (or his username), but the respective user can whenever change it...
what do you call a twitter "profile" ? I guess you talk about the user timeline
according to the api doc, your url should probably look like this :
https://api.twitter.com/1/statuses/user_timeline.html?&user_id=(your_id_here)
however, i would advise to use one of the twitter api gems to ease your pain...

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.

Facebooker with Authlogic is Not Redirecting to the Dashboard After Authorization

Everything seems to be working fine with my implementation of Facebooker with Authlogic (using the authlogic_facebook_connect plugin) except for one thing.
After the initial authorization of the application (by clicking OK on the Facebook pop-up) I still remain on the login page. There is no redirection. However, once I refresh the login page and then click the Facebook button again, there is no popup because it is already authorized by Facebook, instead it redirects to /user_session (for authentication via Facebook session) automatically and immediately takes me to the dashboard page as expected.
Additional Information:
Any idea why it doesn't redirect on the very first click, right after authorizing Facebook? The post-authorize URL is set for http:///user_session/ and the routes for authlogic are set properly.
I have tried with Prototype and jQuery, both give the same results.
You can see the same issue on this tutorial website if you try to authenticate with Facebook. This website is not mine so try at your own risk:
http://facebooker.pjkh.com
Thanks.
Also having the same issue here. I think the reason it was doing nothing for me, using jquery, is the code generated by
<%= authlogic_facebook_login_button :controller => 'customer_session' %>
which is something like
<form id='connect_to_facebook_form' method='post' action='/customer_session'>
<input type='hidden' name='authenticity_token' value='keLV8CIfc5znsRkjhkjhkjhkjhkjh='/>
</form>
<script type='text/javascript' charset='utf-8'>
function connect_to_facebook() {
$('connect_to_facebook_form').submit();
}
</script>
<fb:login-button js="prototype" onlogin="connect_to_facebook()"></fb:login-button>
the jquery to submit the form is wrong it should be
$('#connect_to_facebook_form').submit();
(duh, because I did not pass in :js => :jquery)
but if I fix that I still get
1 error prohibited this customer
session from being saved
There were problems with the following
fields:
* You did not provide any details for authentication
so the right details are not being injected into the form I guess

Resources