How to do Jo Blow is viewing "XYZ" on mysite.com facebook updates? - ruby-on-rails

What is required for me to integrate automatic activity updates on a user's facebook status?
I frequently see things like "Joe Shmoe" is listening to Cornbread And Butter... by Carolina Chocolate D... on Spotify
I'd like to know what it takes to integrate this.
My suppositions:
I imagine the user has to "agree" to this.
The user has to either sign in with Facebook auth, or be signed in?
There is some kind of server-side script that runs when a page loads, or is this an ajax JS library.
Does facebook offer some kind of api for this or JS library for this?
Also I work with Ruby on Rails, so please let me know if there's a gem that facilitates this.
Any info appreciated.

You should probably start here: https://developers.facebook.com/docs/beta/
This is the documentation for the new Open Graph features which include low friction publishing of structured data

Related

Where can I find more information on how to sync up accounts to an APP?

When I say that, I mean if I'm creating an APP that I want to work in conjunction with say instagram, twitch, or facebook, etc, where they log in with their account first, how could I go about that? I'd want to essentially do an ADD-ON and make it more accessible/easy for users. Where could I learn more about how to do that?
It sounds a big vague I know, but I'm not sure how else to explain it.
You are looking for an OAUTH API from any of those providers, if I am understanding your post correctly.
You would read the documentation at their relative websites and then apply what is necessary to your project.
More info on facebook here: https://developers.facebook.com/docs/reference/dialogs/oauth

Is there a social plugin to post on walls/tweet directly to a person?

Is there currently a social plugin or a way to post directly to someone's wall or tweet directly at someone?
For example, say I have a list of people on my page:
Nicholas Cage
Robin Williams
Kiss
Pink
Is there a way to post to their wall/tweet without leaving my page? I currently have it set that it opens their page in a new window, but it would be much more usable to be able to do it this way.
You could do that in the background from the server, but if the social site asks for a confirmation, you'll have to go back to the user again. As all top social sites ask for confirmation you would only catch users who confirmed before... If this is worth the effort is up to you.

Tracking users' clicks and page visits in Rails

I would like to monitor users' page visits and clicks in my Rails app to make recommendations. My questions are:
Is there a Rails gem for this, or Google Analytics is the standard? If latter is true, then how should I link a page visit to a particular user profile?
It is typical in Rails to have a section in application.html.erb, which is shared for all pages. If I add Google Analytics pageview tracking code to in application.html.erb, will it be able to track all individual pages?
There are other ways, but the vast majority probably use Google Analytics. Several gems exist that help you integrate with GA to get at the data. See here: https://www.ruby-toolbox.com/categories/Web_Analytics.
Based on your first question, it seems you may want more insight than GA can provide. I've used ClickTale (http://www.clicktale.com) and Woopra (http://www.woopra.com) before, to good effect. This article lists several other alternatives, too - notice the high marks for Clicky: http://imimpact.com/web-stats-alternatives-to-google-analytics/.
Google Analytics (and almost all of these others) will take care of your second question automatically whenever the user loads a new page, since it keyed by URL. That means that, although you put the GA script code in a single place, each unique page is tracked individually.
If you have AJAX requests that change that page without changing the URL, you'll need to dig in to the GA script API. Essentially you'll need to push a new url (possibly with a # in it) whenever you want to track an AJAX-driven link/button click. See here: http://davidwalsh.name/ajax-analytics
I am biased, but I would recommend checking out impressionist, if you need to integrate the page views into the app in real-time. With analytics you will always have some lag time and you are also relying on an external dependency. Impressionist is good if you need this kind of control, but if you are just looking for simple metrics and don't need to pull them into the app, then analytics is probably the way to go.
Check out Ahoy, at https://github.com/ankane/ahoy. With just a few lines of code in your app, you can track page views and tie them to user accounts.
You can further customize Ahoy to track custom events, both the client (with JavaScript) and server.
Ahoy does not depend on any third-party services.

Some questions about dotnetopenauth

I have a couple outstanding questions mainly reguarding twitter and facebook
In the FacebookGraph class there are properties such as Id,name,etc. I am wondering how do I add to this list? Like what happens if I want a users hometown? I tried to add a property called hometown but it always is null.
What should I store their id(1418) or the whole url(http://www.facebook.com/profile.php?id=1418) for lookup later in my db to grab their data and to see if they have an account with my site?
Is it actually good to use this id as it seems like it is common knowledge. Can't someone just find the profile id or whatever and do a fake request on my site?
how do you setup dotnetopenauth to deal with the case when a user goes to facebook and deletes access to my website. I know you can send a deauthorization code to your site and then delete their account but I don't know how to do that through dotnetopenauth
Twitter
Is it possible to do number 4 with twitter?
Ajax
Is it possible to make the openid stuff ajax? I don't see a sample anywhere in the dotnetopenauth samples.
I'm no pro at Facebook. But the FacebookGraph class is in the ApplicationBlock, which ships as source and is fully intended for you to customize or extend within your own application. Hopefully people more familiar with Facebook in particular, or the Facebook docs, can help you with those questions.
Since Facebook is not OpenID, what you store whether ID # or the whole URL, is less critical. People should not be able to just craft requests to log in as others because your site should be verifying signatures, etc. If you're using DotNetOpenAuth appropriately this is probably being done automatically for you. But without seeing your code it can't be said for sure.
Assume the id is common knowledge. It certainly isn't a long random number so anyone can guess it. The ID must be accompanied by a signature that verifies that Facebook sent the ID, just now, for you.
I suspect the deauthorization code isn't going to be relevant to DotNetOpenAuth -- that's probably just some URL that you respond to. But again, I haven't read the FB docs on this.
Here's the real answer I can give you. Yes, OpenID works with AJAX reasonably well. You can see some samples of this at nerddinner.com or a sample of a blog post comment system. The most complete AJAX demonstration for standard login may be in the web forms or MVC project templates available on the Visual Studio Gallery.

How to let users post links/images to Facebook, Twitter, Buzz etc... from a Rails based website?

I'd like to offer users the ability to post images / links to articles from my web application to Facebook, Twitter, Buzz and any other social network.
A perfect example of the functionality I'm trying to replicate is mashable.com ... where each social network is represented by an icon that a) shows the number of shares AND b) allows users to click on it to post to that specific network.
Don't know if it matters ... but the site is built using RoR.
Thanks
Here are the links for adding those social media buttons to your site:
Facebook:
http://wiki.developers.facebook.com/index.php/Facebook_Share
Twitter:
http://help.tweetmeme.com/2009/04/06/tweetmeme-button/
Buzz:
http://www.google.com/buzz/api/admin/configPostWidget
I would first study the available APIs/Webservice documentations of Facebook, Twitter etc. You will learn if and how your features could be implemented. After that you have to write clients for each service. It doesn't matter if you are using Rails or another framework, Ruby or another language. It's all about HTTP requests/responses (or SOAP). There's also a good chance that somebody has already written a library, plugin or gem for your tasks.

Resources