rawapi 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest.txt +5 -0
- data/lib/rawapi/entry.rb +7 -0
- data/lib/rawapi/feed.rb +7 -0
- data/lib/rawapi/item.rb +7 -0
- data/lib/rawapi/referer.rb +3 -0
- data/lib/rawapi/response.rb +42 -0
- data/lib/rawapi/version.rb +1 -1
- data/lib/rawapi.rb +48 -8
- metadata +7 -2
data/Manifest.txt
CHANGED
data/lib/rawapi/entry.rb
ADDED
data/lib/rawapi/feed.rb
ADDED
data/lib/rawapi/item.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# The Response object is the ruby object version of the webservice response.
|
2
|
+
class Response
|
3
|
+
attr_accessor :status, :code, :message, :feeds
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@feeds = []
|
7
|
+
end
|
8
|
+
|
9
|
+
# returns a formated string representing the response object. good for debugging.
|
10
|
+
def to_s
|
11
|
+
output = []
|
12
|
+
output << "Status: #{@status}"
|
13
|
+
output << "Code: #{@code}" if @code
|
14
|
+
output << "Message: #{@message}" if @message
|
15
|
+
for feed in @feeds
|
16
|
+
output << "-Feed"
|
17
|
+
output << " Id: #{feed.id}" if feed.id
|
18
|
+
output << " URI: #{feed.uri}" if feed.uri
|
19
|
+
for entry in feed.entries
|
20
|
+
output << " -Entry"
|
21
|
+
output << " Date: #{entry.date}" if entry.date
|
22
|
+
output << " Circulation: #{entry.circulation}" if entry.circulation
|
23
|
+
output << " Hits: #{entry.hits}" if entry.hits
|
24
|
+
for item in entry.items
|
25
|
+
output << " -Item"
|
26
|
+
output << " Title: #{item.title}" if item.title
|
27
|
+
output << " URL: #{item.url}" if item.url
|
28
|
+
output << " ItemViews: #{item.itemviews}" if item.itemviews
|
29
|
+
output << " Clickthoughs: #{item.clickthroughs}" if item.clickthroughs
|
30
|
+
for referer in item.referers
|
31
|
+
output << " -Referer"
|
32
|
+
output << " URL: #{referer.url}" if referer.url
|
33
|
+
output << " ItemViews: #{referer.itemviews}" if referer.itemviews
|
34
|
+
output << " Clickthoughs: #{referer.clickthroughs}" if referer.clickthroughs
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
return output.join("\n")
|
41
|
+
end
|
42
|
+
end
|
data/lib/rawapi/version.rb
CHANGED
data/lib/rawapi.rb
CHANGED
@@ -4,9 +4,25 @@ require 'open-uri'
|
|
4
4
|
require 'rexml/document'
|
5
5
|
include REXML
|
6
6
|
|
7
|
+
# Class to provide the interface to the Awareness API
|
8
|
+
#
|
9
|
+
# dates:
|
10
|
+
# * Individual dates always use this format: YYYY-MM-DD
|
11
|
+
# * Date ranges are expressed with a comma: YYYY-MM-D1, YYYY-MM-D7 means all dates between and including D1 and D7
|
12
|
+
# * If a range is specified, the second date must always be later than the first date
|
13
|
+
# * A single date will be interpreted as a range of one date: YYYY-MM-D1 = YYYY-MM-D1, YYYY-MM-D1
|
14
|
+
# * Discrete ranges are separated by a slash: YYYY-MM-D1/YYYY-MM-D5/YYYY-MM-D7,YYYY-MM-D14 means D1 and D5 and all dates between and including D7 and D14. Multiple discrete ranges may also be provided by using multiple date parameters in a single GET request.
|
15
|
+
# * If no date is specified, Yesterday's date is assumed. "Current" is always yesterday's data. "Live" daily data is not yet available.
|
16
|
+
# * An individual date starts at 12am CDT (GMT -5) and ends 12am CDT the next day. Custom timezone support is not yet available.
|
7
17
|
class AwarenessApi
|
8
18
|
ROOT_API_URL = 'http://api.feedburner.com/awareness/1.0/'
|
9
19
|
|
20
|
+
# Get Basic Feed Awareness Data
|
21
|
+
#
|
22
|
+
# options:
|
23
|
+
# * uri: The URI of the feed (same as http://feeds.feedburner.com/<feeduri>) Must be used if id is not specified
|
24
|
+
# * id: The FeedBurner id of the feed (visible when editing a feed in your account, e.g., http://www.feedburner.com/fb/a/optimize?id=<id>). May be used instead if uri is not specified.
|
25
|
+
# * dates: Dates are used to specify the period for which data is need (see note on dates above)
|
10
26
|
def get_feed_data(options)
|
11
27
|
option_string = parse_options(options)
|
12
28
|
|
@@ -14,6 +30,13 @@ class AwarenessApi
|
|
14
30
|
return parse_xml(response_xml)
|
15
31
|
end
|
16
32
|
|
33
|
+
# Get Individual Item Awareness Data (TotalStats pro)
|
34
|
+
#
|
35
|
+
# options:
|
36
|
+
# * uri: The URI of the feed (same as http://feeds.feedburner.com/<feeduri>) Must be used if id is not specified
|
37
|
+
# * id: The FeedBurner id of the feed (visible when editing a feed in your account, e.g., http://www.feedburner.com/fb/a/optimize?id=<id>). May be used instead if uri is not specified.
|
38
|
+
# * itemurl: The source URL of item (not the FeedBurner generated URL, but the original source URL). Multiple itemurl parameters may be provided in a single request in order to retrieve additional items.
|
39
|
+
# * dates: Dates are used to specify the period for which data is need (see note on dates above)
|
17
40
|
def get_item_data(options)
|
18
41
|
option_string = parse_options(options)
|
19
42
|
|
@@ -21,13 +44,19 @@ class AwarenessApi
|
|
21
44
|
return parse_xml(response_xml)
|
22
45
|
end
|
23
46
|
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
47
|
+
# Get Resyndication Feed Awareness Data (TotalStats pro)
|
48
|
+
#
|
49
|
+
# options:
|
50
|
+
# * uri: The URI of the feed (same as http://feeds.feedburner.com/<feeduri>)
|
51
|
+
# * id: The FeedBurner id of the feed (visible when editing a feed in your account, e.g., http://www.feedburner.com/fb/a/optimize?id=<id>). May be used instead if uri is not specified.
|
52
|
+
# * itemurl: The source URL of item (not the FeedBurner generated URL, but the original source URL). Multiple itemurl parameters may be provided in a single request in order to retrieve additional items.
|
53
|
+
# * dates: Dates are used to specify the period for which data is need (see note on dates above)
|
54
|
+
def get_resyndication_data(options)
|
55
|
+
option_string = parse_options(options)
|
56
|
+
|
57
|
+
response_xml = open("#{ROOT_API_URL}GetResyndicationData?#{option_string}").read
|
58
|
+
return parse_xml(response_xml)
|
59
|
+
end
|
31
60
|
|
32
61
|
private
|
33
62
|
def parse_options(options)
|
@@ -76,6 +105,16 @@ class AwarenessApi
|
|
76
105
|
item.clickthroughs = item_node.attributes['clickthroughs']
|
77
106
|
|
78
107
|
entry.items << item
|
108
|
+
|
109
|
+
for referer_node in item_node.elements
|
110
|
+
referer = Referer.new
|
111
|
+
|
112
|
+
referer.url = referer_node.attributes['url']
|
113
|
+
referer.itemviews = referer_node.attributes['itemviews']
|
114
|
+
referer.clickthroughs = referer_node.attributes['clickthroughs']
|
115
|
+
|
116
|
+
item.referers << referer
|
117
|
+
end
|
79
118
|
end
|
80
119
|
end
|
81
120
|
end
|
@@ -89,4 +128,5 @@ end
|
|
89
128
|
# opts = {:uri => 'CommonThread', :dates => '2007-03-20,2007-03-23'}
|
90
129
|
#
|
91
130
|
# puts rawapi.get_feed_data(opts)
|
92
|
-
# puts rawapi.get_item_data(opts)
|
131
|
+
# puts rawapi.get_item_data(opts)
|
132
|
+
# puts rawapi.get_resyndication_data(opts)
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rawapi
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2007-03-
|
6
|
+
version: 0.1.2
|
7
|
+
date: 2007-03-26 00:00:00 -05:00
|
8
8
|
summary: Ruby interface to the FeedBurner Awareness API.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -35,6 +35,11 @@ files:
|
|
35
35
|
- README.txt
|
36
36
|
- Rakefile
|
37
37
|
- lib/rawapi.rb
|
38
|
+
- lib/rawapi/entry.rb
|
39
|
+
- lib/rawapi/feed.rb
|
40
|
+
- lib/rawapi/item.rb
|
41
|
+
- lib/rawapi/response.rb
|
42
|
+
- lib/rawapi/referer.rb
|
38
43
|
- lib/rawapi/version.rb
|
39
44
|
- setup.rb
|
40
45
|
- test/test_helper.rb
|