instapi 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/bookmark.rb +1 -1
- data/examples/get_unread.rb +1 -1
- data/lib/instapi/version.rb +1 -1
- data/lib/instapi.rb +6 -11
- metadata +1 -1
data/examples/bookmark.rb
CHANGED
data/examples/get_unread.rb
CHANGED
data/lib/instapi/version.rb
CHANGED
data/lib/instapi.rb
CHANGED
@@ -8,20 +8,15 @@ class Instapi
|
|
8
8
|
|
9
9
|
def initialize(username, password)
|
10
10
|
@username, @password = username, password
|
11
|
-
self
|
12
11
|
end
|
13
12
|
|
14
13
|
def client
|
15
14
|
return @client if @client
|
16
15
|
@client = HTTPClient.new
|
16
|
+
@client.post("#{BASE_URL}/user/login", :username => username, :password => password)
|
17
17
|
@client
|
18
18
|
end
|
19
19
|
|
20
|
-
def login!
|
21
|
-
client.post("#{BASE_URL}/user/login", :username => username, :password => password)
|
22
|
-
self
|
23
|
-
end
|
24
|
-
|
25
20
|
def add(url, options = {})
|
26
21
|
get('/api/add', {:url => url, :username => username, :password => password}.merge(options))
|
27
22
|
end
|
@@ -42,15 +37,15 @@ class Instapi
|
|
42
37
|
get("/delete/#{id}")
|
43
38
|
end
|
44
39
|
|
45
|
-
def
|
40
|
+
def get(path, params = {})
|
41
|
+
client.get_content(BASE_URL + path, params)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.text(url)
|
46
45
|
doc = Nokogiri::HTML(get("/text?u=#{url}"))
|
47
46
|
{
|
48
47
|
:title => doc.css('title').first.text,
|
49
48
|
:text => doc.css('#story').first.inner_html
|
50
49
|
}
|
51
50
|
end
|
52
|
-
|
53
|
-
def get(path, params = {})
|
54
|
-
client.get_content(BASE_URL + path, params)
|
55
|
-
end
|
56
51
|
end
|