Created
January 28, 2010 09:29
-
-
Save marshluca/288579 to your computer and use it in GitHub Desktop.
给twitter插件加上可用代理proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'forwardable' | |
require 'rubygems' | |
require 'uri' | |
gem 'oauth', '~> 0.3.6' | |
require 'oauth' | |
gem 'hashie', '~> 0.1.3' | |
require 'hashie' | |
gem 'httparty', '~> 0.4.3' | |
require 'httparty' | |
module Twitter | |
class TwitterError < StandardError | |
attr_reader :data | |
def initialize(data) | |
@data = data | |
super | |
end | |
end | |
class RateLimitExceeded < TwitterError; end | |
class Unauthorized < TwitterError; end | |
class General < TwitterError; end | |
class Unavailable < StandardError; end | |
class InformTwitter < StandardError; end | |
class NotFound < StandardError; end | |
All_options = {:format => :json,:http_proxyaddr=>'203.113.112.246',:http_proxyport=>'8088'} | |
def self.firehose | |
response = HTTParty.get('http://twitter.com/statuses/public_timeline.json',All_options) | |
response.map { |tweet| Hashie::Mash.new(tweet) } | |
end | |
def self.user(id) | |
response = HTTParty.get("http://twitter.com/users/show/#{id}.json", All_options ) | |
Hashie::Mash.new(response) | |
end | |
def self.status(id) | |
response = HTTParty.get("http://twitter.com/statuses/show/#{id}.json", All_options) | |
Hashie::Mash.new(response) | |
end | |
def self.friend_ids(id) | |
HTTParty.get("http://twitter.com/friends/ids/#{id}.json", All_options) | |
end | |
def self.follower_ids(id) | |
HTTParty.get("http://twitter.com/followers/ids/#{id}.json", All_options) | |
end | |
def self.timeline(id, options={}) | |
response = HTTParty.get("http://twitter.com/statuses/user_timeline/#{id}.json", All_options.merge({:query=>options})) | |
response.map{|tweet| Hashie::Mash.new tweet} | |
end | |
end | |
directory = File.expand_path(File.dirname(__FILE__)) | |
require File.join(directory, 'twitter', 'oauth') | |
require File.join(directory, 'twitter', 'httpauth') | |
require File.join(directory, 'twitter', 'request') | |
require File.join(directory, 'twitter', 'base') | |
require File.join(directory, 'twitter', 'search') | |
require File.join(directory, 'twitter', 'trends') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment