Ruby libs for Twitter User/Site streams? - ruby

Are there any ruby libs to handle twitter user / site streams?

the twitter-stream gem can do that.
http://rubygems.org/gems/twitter-stream

https://github.com/scootklein
currently has user streams, working on site streams (very much beta, and planning on integrating back into the parent fork)

Related

Ruby on Rails with chargify

I want to integrate chargify to my rails app. I have user object and I want the user to be able to subscribe for one month and update the boolean column on user object. I prefer to use the API not hosted pages. How can I do that?
Is there any example for chargify on ruby on rails for handling subscriptions but with details about mvc for newbies?
Based on this thread and the Googles it looks like there is not a whole lot out there.
You could try looking at the Rails 2 example here and converting it or use the gem here (gem "chargify", "~> 0.3.0").
I know none of this is aimed at newbies but the info seems to sparse.
This might get you going. It seems that Chartify itself is written in Rails, and therfore their API is ruby code, which you can use...

Attachment_fu or Paperclip for Rails3

I have just upgraded to rails3 and when I installed my usual attachment_fu plugin failed. So I started googling it and although I did manage to find a rails3 version there seemed to be a lot more people talking about paperclip with rails3.
So firstly what are the advantages of paperclip?
Is there better support for rails3 with it?
Neither. Use carrierwave .
To handle the file uploads, I’ve switched from Paperclip to CarrierWave. While Paperclip has (and continues) to serve me well in many applications I work with, I really appreciate the modular approach that CarrierWave takes. It’s agnostic as to which of the popular S3 clients you use, supporting both aws/s3 and right_aws. It’s also ORM agnostic and not tightly coupled to Active Record. The tight coupling of Paperclip has caused us some grief at work, and I’m also confused about the state of Paperclip’s support for aws/s3 and right_aws. So, I was happy to find this new project, and the maintainer Jonas Nicklas seems to be an extremely responsive and helpful dude, which is always good thing. The code looks great, and I’ve had an easy time working with this library so far. (from: http://trevorturk.com/2010/2/8/kzak-an-open-source-web-based-jukebox/)
More info here:
http://techblog.moviepilot.com/carrierwave-as-a-replacement-for-paperclip
I made attachment_fu rails3 compatible.
See https://github.com/mihael/attachment_fu
EDIT: but it is broken for some users, and i am not maintaining it further, so please look into other solutions, if you do not want to hack it yourself ;)
I tested paperclip vs carrierwave vs attachment_fu with rails3.0.3 for a project I am working on.
So far attachment_fu works very well as always, but the code still needs some refactoring with the callback system. It has backends for cloudfiles, s3.
Paperclip is also very good and is very easy to use. The basic setup did not let me upload movies (had to add option :whiny=>false), and it did not sanitize filenames the way I expected. This is how I did it:
class Asset < ActiveRecord::Base
has_attached_file :file, :styles => { :small => "300x300>", :thumb => "50x50>" }, :whiny => false
before_create :sanitize_file_name
private
def sanitize_file_name
self.file.instance_write( :file_name, file_file_name.gsub(/[^A-Za-z0-9\.\-]/, '_'))
end
end
Paperclip has s3 backend, but does not have a backend for cloudfiles built-in. There is a paperclip fork for that (google for paperclip-cloudfiles) which is built for rails2.3.5 (search github for paperclip_demo).
Carrierwave looks very nice, with the decoupled architecture, but I do not like the fact that it does not delete stuff on updates and destroys of objects, leaving a bunch of files and directories on disk. The basic carrierwave setup also did not let me upload movies, although it sanitizes filenames nicely. I did not found a quick fix for this, yet. If You are using Mongoid and GridFS, carrierwave has built in support.
Finally, I took Paperclip for my project.
I've created a gem for attachment_fu if you want to continue using it in Rails 3.2 and beyond.
https://rubygems.org/gems/pothoven-attachment_fu
Dragonfly is really good. Try it out, it can handle files and images.

Is there a Twitter Streams API for Ruby?

Does anyone know of a Ruby gem or plugin that provides a simple interface to the Twitter Steams API?
Try TweetStream: https://github.com/intridea/tweetstream
Twitter Gem has added streaming functionality.
you can check that out

Twitter OAuth with MGTwitterEngine

I'm using the MGTwitterEngine to connect to twitter and I want to use OAuth with the MGTwitterEngine?
The master branch has merged OAuth and xAuth support back in.
There's a modified version of MGTwitterEngine on GitHub that is supposed to use OAuth: http://github.com/kimptoc/MGTwitterEngine-1.0.8-OAuth/
i would highly suggest using xAuth instead of OAuth as the process on the user's end doesn't at all change. i wrote a tutorial about how I got it to work on iPhone only if it helps. http://www.2bros1blog.com/2010/07/switching-from-basic-to-xauth-with-mgtwitterengine-on-iphone/
I suspect that if the MGTwitterEngine doesn't implement OAuth, it soon will, or will need support for it soon.
I'd suggest seeing if the current development version supports it, and if not -- and you have the motivation -- working on a patch for this functionality.
After having a look at STTwitter, FHSTwitterEngine and MGTwitterEngine I ended up using OAuthConsumer available through github.
My reasons for this were that I was writing an app for Mac OSX Lion in XCode with Objective-C. Most of the OAuth/Twitter code out there was either for other languages, iOS-specific or quite out of date and full of deprecated calls.
Apple's SDK 10.8 now has a social.framework (includes SLRequest) and and accounts.framework (includes ACAccount) which should be really useful for accessing FB, Twitter and some other social site I didn't recognise. Unfortunately that was no good for me working under 10.7 so I did not try those out practically. Would be interested to know anyone's experiences under 10.8.
OAuthConsumer was really straight forward to use to get through Twitter's API properly and is available in a few different languages. You do need to sort out your own JSON etc. but that's pretty straight-forward with NSJSONSerialization etc.
I've written up more detail on this on my blog Twitter OAuth Cocoa. If you need an OAuth, twitter-friendly bit of code, and the function-rich twitter engines aren't working for you then I'd recommend OAuthConsumer.

Twitter/Facebook API for Ruby

I want to write a Ruby application through which:
I can submit tweets to twitter.
I can submit a post to facebook.
I can manage real-time stats of tweets
Is there any twitter/facebook api for Ruby?
I use the Twitter gem and am quite happy with it.
For Facebook, there is the Facebooker gem.
Streams of tweets:
Tweetmon is a great gem for keeping real-time track of tweets. Here's an example of using it to get a stream of tweets on a specific keyword
#!/usr/local/bin/ruby
if ARGV.size==1
keyword = ARGV.shift
else
puts 'tweetmon usage: tweetmon <keyword>'
exit 1
end
require 'yaml'
require 'rubygems'
require 'tweetstream'
config = YAML::load(File.open(File.expand_path('~/.twitter')))
user =config['username']
password =config['password']
TweetStream::Client.new(user,password).track(keyword) do |status|
puts "[#{status.created_at}-#{status.user.screen_name}] #{status.text}"
end
To use this gem you need:
gem sources -a http://gems.github.com
gem install intridea-tweetstream
To submit a tweet is just a HTTP POST - doesn't need any extra libraries to do this.
The Twitter API is a RESTful web service. It's completely language agnostic. Use whatever language you want.
Not sure about Facebook.
Two more libraries that didn't get mentioned yet:
twitter4r: http://twitter4r.rubyforge.org/
Twibot: http://cjohansen.no/en/ruby/twibot_a_microframework_for_twitter_bots_in_ruby
If you're inclined to retain more control over how you use the Twitter and Facebook APIs you can use the Wrest gem.
Take a look at the facebook (http://is.gd/bJspX) and twitter (http://is.gd/bJsqV) examples.
Also, while both the Twitter and Facebook APIs are HTTP APIs, they are not RESTful despite their claims to the contrary.
I would use this gem, it's really helpful https://github.com/moomerman/twitter_oauth
or just gem install twitter_oauth
MiniFB https://github.com/appoxy/mini_fb is excellent for Facebook API. But in both APIs you can do everything through HTTPParty and OAuth.

Resources