Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added 3rd party api endpoint support for Tumblr, etc

  • Loading branch information...
commit c5550f1317538638b754d6b0dbbb372e069b5580 1 parent 2571cd8
Wynn Netherland authored
View
5 lib/twitter/base.rb
@@ -12,7 +12,7 @@ def initialize(client)
# Options: since_id, max_id, count, page
def home_timeline(query={})
- perform_get('http://api.twitter.com/1/statuses/home_timeline.json', :query => query)
+ perform_get('/statuses/home_timeline.json', :query => query)
end
# Options: since_id, max_id, count, page, since
@@ -218,8 +218,7 @@ def list_delete(list_owner_username, slug)
end
def lists(list_owner_username=nil)
- path = "http://api.twitter.com/1"
- path += "/#{list_owner_username}" if list_owner_username
+ path = "/#{list_owner_username}" if list_owner_username
path += "/lists.json"
perform_get(path)
end
View
3  lib/twitter/httpauth.rb
@@ -8,7 +8,8 @@ class HTTPAuth
def initialize(username, password, options={})
@username, @password = username, password
@options = {:ssl => false}.merge(options)
- self.class.base_uri "http#{'s' if options[:ssl]}://twitter.com"
+ options[:api_endpoint] ||= "twitter.com"
+ self.class.base_uri "http#{'s' if options[:ssl]}://#{options[:api_endpoint]}"
end
def get(uri, headers={})
View
16 test/twitter/base_test.rb
@@ -28,7 +28,7 @@ class BaseTest < Test::Unit::TestCase
context "hitting the api" do
should "be able to get home timeline" do
- stub_get('http://api.twitter.com/1/statuses/home_timeline.json', 'home_timeline.json')
+ stub_get('/statuses/home_timeline.json', 'home_timeline.json')
timeline = @twitter.home_timeline
timeline.size.should == 20
first = timeline.first
@@ -219,7 +219,7 @@ class BaseTest < Test::Unit::TestCase
end
should "be able to view lists for the authenticated user" do
- stub_get('http://api.twitter.com/1/pengwynn/lists.json', 'lists.json')
+ stub_get('/pengwynn/lists.json', 'lists.json')
lists = @twitter.lists('pengwynn').lists
lists.size.should == 1
lists.first.name.should == 'Rubyists'
@@ -316,7 +316,17 @@ class BaseTest < Test::Unit::TestCase
end
end
+ end
+
+ context "when using a non-twitter service" do
+ setup do
+ @twitter = Twitter::Base.new(Twitter::HTTPAuth.new('wynn@example.com', 'mypass', :api_endpoint => 'tumblr.com'))
+ end
-
+ should "get the home timeline" do
+ stub_get('http://wynn%40example.com:mypass@tumblr.com/statuses/home_timeline.json', 'home_timeline.json')
+ timeline = @twitter.home_timeline
+ timeline.size.should == 20
+ end
end
end

0 comments on commit c5550f1

Please sign in to comment.
Something went wrong with that request. Please try again.