gnip-gnip 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/README +144 -0
  2. data/Rakefile +221 -0
  3. data/TODO +72 -0
  4. data/bin/gnip +651 -0
  5. data/doc/api.html +1201 -0
  6. data/gemspec.rb +25 -0
  7. data/gnip-ruby.gemspec +26 -0
  8. data/lib/gnip.rb +71 -0
  9. data/lib/gnip/activity.rb +665 -0
  10. data/lib/gnip/api.rb +191 -0
  11. data/lib/gnip/arguments.rb +21 -0
  12. data/lib/gnip/blankslate.rb +5 -0
  13. data/lib/gnip/config.rb +144 -0
  14. data/lib/gnip/filter.rb +311 -0
  15. data/lib/gnip/list.rb +126 -0
  16. data/lib/gnip/options.rb +96 -0
  17. data/lib/gnip/orderedhash.rb +199 -0
  18. data/lib/gnip/publisher.rb +316 -0
  19. data/lib/gnip/resource.rb +301 -0
  20. data/lib/gnip/template.rb +44 -0
  21. data/lib/gnip/util.rb +120 -0
  22. data/sample/data/activity.yml +21 -0
  23. data/test/auth.rb +60 -0
  24. data/test/config.yml +2 -0
  25. data/test/data/activity.xml +14 -0
  26. data/test/data/activity_only_required.xml +4 -0
  27. data/test/data/activity_with_payload.xml +22 -0
  28. data/test/data/activity_with_place.xml +18 -0
  29. data/test/data/activity_with_place_wo_bounds.xml +36 -0
  30. data/test/data/activity_with_unbounded_media_urls.xml +44 -0
  31. data/test/data/activity_without_bounds.xml +24 -0
  32. data/test/helper.rb +115 -0
  33. data/test/integration/auth.rb +12 -0
  34. data/test/integration/publisher.rb +86 -0
  35. data/test/lib/shoulda.rb +9 -0
  36. data/test/lib/shoulda/action_controller.rb +28 -0
  37. data/test/lib/shoulda/action_controller/helpers.rb +47 -0
  38. data/test/lib/shoulda/action_controller/macros.rb +277 -0
  39. data/test/lib/shoulda/action_controller/matchers.rb +37 -0
  40. data/test/lib/shoulda/action_controller/matchers/assign_to_matcher.rb +109 -0
  41. data/test/lib/shoulda/action_controller/matchers/filter_param_matcher.rb +57 -0
  42. data/test/lib/shoulda/action_controller/matchers/render_with_layout_matcher.rb +81 -0
  43. data/test/lib/shoulda/action_controller/matchers/respond_with_content_type_matcher.rb +70 -0
  44. data/test/lib/shoulda/action_controller/matchers/respond_with_matcher.rb +77 -0
  45. data/test/lib/shoulda/action_controller/matchers/route_matcher.rb +93 -0
  46. data/test/lib/shoulda/action_controller/matchers/set_session_matcher.rb +83 -0
  47. data/test/lib/shoulda/action_controller/matchers/set_the_flash_matcher.rb +85 -0
  48. data/test/lib/shoulda/action_mailer.rb +10 -0
  49. data/test/lib/shoulda/action_mailer/assertions.rb +38 -0
  50. data/test/lib/shoulda/action_view.rb +10 -0
  51. data/test/lib/shoulda/action_view/macros.rb +56 -0
  52. data/test/lib/shoulda/active_record.rb +16 -0
  53. data/test/lib/shoulda/active_record/assertions.rb +69 -0
  54. data/test/lib/shoulda/active_record/helpers.rb +40 -0
  55. data/test/lib/shoulda/active_record/macros.rb +586 -0
  56. data/test/lib/shoulda/active_record/matchers.rb +42 -0
  57. data/test/lib/shoulda/active_record/matchers/allow_mass_assignment_of_matcher.rb +83 -0
  58. data/test/lib/shoulda/active_record/matchers/allow_value_matcher.rb +102 -0
  59. data/test/lib/shoulda/active_record/matchers/association_matcher.rb +226 -0
  60. data/test/lib/shoulda/active_record/matchers/ensure_inclusion_of_matcher.rb +87 -0
  61. data/test/lib/shoulda/active_record/matchers/ensure_length_of_matcher.rb +141 -0
  62. data/test/lib/shoulda/active_record/matchers/have_db_column_matcher.rb +169 -0
  63. data/test/lib/shoulda/active_record/matchers/have_index_matcher.rb +105 -0
  64. data/test/lib/shoulda/active_record/matchers/have_named_scope_matcher.rb +125 -0
  65. data/test/lib/shoulda/active_record/matchers/have_readonly_attribute_matcher.rb +59 -0
  66. data/test/lib/shoulda/active_record/matchers/validate_acceptance_of_matcher.rb +41 -0
  67. data/test/lib/shoulda/active_record/matchers/validate_numericality_of_matcher.rb +39 -0
  68. data/test/lib/shoulda/active_record/matchers/validate_presence_of_matcher.rb +60 -0
  69. data/test/lib/shoulda/active_record/matchers/validate_uniqueness_of_matcher.rb +148 -0
  70. data/test/lib/shoulda/active_record/matchers/validation_matcher.rb +56 -0
  71. data/test/lib/shoulda/assertions.rb +59 -0
  72. data/test/lib/shoulda/autoload_macros.rb +46 -0
  73. data/test/lib/shoulda/context.rb +304 -0
  74. data/test/lib/shoulda/helpers.rb +8 -0
  75. data/test/lib/shoulda/macros.rb +73 -0
  76. data/test/lib/shoulda/private_helpers.rb +20 -0
  77. data/test/lib/shoulda/proc_extensions.rb +14 -0
  78. data/test/lib/shoulda/rails.rb +13 -0
  79. data/test/lib/shoulda/rspec.rb +9 -0
  80. data/test/lib/shoulda/tasks.rb +3 -0
  81. data/test/lib/shoulda/tasks/list_tests.rake +29 -0
  82. data/test/lib/shoulda/tasks/yaml_to_shoulda.rake +28 -0
  83. data/test/lib/shoulda/test_unit.rb +19 -0
  84. data/test/lib/xmlsimple.rb +1021 -0
  85. data/test/loader.rb +25 -0
  86. data/test/unit/activity.rb +26 -0
  87. data/test/unit/util.rb +39 -0
  88. metadata +158 -0
@@ -0,0 +1,1201 @@
1
+
2
+ *Gnip API v2.1 (https://demo-v21.gnip.com) *(doc rev 12)
3
+
4
+ This document is divided into three sections:
5
+
6
+
7
+ * Introduction to the Gnip Platform <#Introduction>
8
+ o Before you can do anything you'll need an account. Get one
9
+ here <https://demo-v21.gnip.com/>.
10
+ * Overview of the Gnip Platform <#Overview>
11
+ * Examples <#Examples>
12
+ o Gnip Activities <#Examples_of_Activities>
13
+ o Data Consumers <#Examples_for_Subscribers>
14
+ o Publishers <#Examples_for_Publishers>
15
+ * Gnip Platform Capabilities and Terminology
16
+ <#Platform_Capabilities_and_Terminology>
17
+ o Publisher and Filter Scoping
18
+ o Activity Buckets
19
+ o Convenience Libraries <http://github.com/gnip>
20
+ o Current list of Publishers
21
+ <https://demo-v21.gnip.com/publishers.html>
22
+ o Gnip XML schema document
23
+ <https://demo-v21.gnip.com/schema/gnip.xsd>
24
+
25
+ *
26
+ Introduction to the Gnip Platform*
27
+
28
+
29
+ Gnip provides a set of services for accessing, filtering and integrating
30
+ data from web APIs and feeds. To get started using the Gnip Platform
31
+ first create an account. You can create one here
32
+ <https://demo-v21.gnip.com/> in seconds. The Gnip Platform API is based
33
+ on the REST approach (see Wikipedia for the explanation
34
+ <http://en.wikipedia.org/wiki/Representational_State_Transfer> if you
35
+ need one), and we provide convenience libraries for several popular
36
+ languages (PHP, Java, .NET, Python, Perl and Ruby), so you can be up and
37
+ running in the language or your choice in no time. The Gnip API
38
+ version of this document is 2.1. At Gnip we use the hostname as the way
39
+ to version the API, this means to access the 2.1 version of the Gnip
40
+ API, you will need to use the host: *https://demo-v21.gnip.com*
41
+ <https://demo-v21.gnip.com/>*.
42
+ *
43
+
44
+
45
+ There are two main data integration use cases supported by the Gnip
46
+ Platform: Publishers & Data Consumers. Publishers represent sources of
47
+ data available through Gnip Platform from different web APIs and feeds
48
+ across the Internet, and Data Consumers, represent the developers and
49
+ companies that use the Gnip Platform to access, filter and integrate
50
+ social and business data into their applications. Developers have the
51
+ choice of using the Gnip Developer Site <http://prod.gnipcentral.com> or
52
+ the Gnip Platform APIs to integrate data.
53
+
54
+
55
+ The Gnip Platform APIs provides access to normalized *event* data. An
56
+ *activity* contains all event meta-data and the data payload. The data
57
+ payload represents the full raw data, from a data source (e.g, such
58
+ Digg, Delicious, Twitter, Sixapart, etc). A *notification* is the
59
+ subset of an *activity *and contains all the event meta-data, just no
60
+ data payload. By providing these two options developers obtain the
61
+ flexibility to request the type of data needed for their application and
62
+ use case. Also, the data payloads included in an *activity* provide
63
+ the raw, original, untouched (though encoded) event information from
64
+ the data source that Gnip maps to the normalized Gnip XML. Gnip maps
65
+ as much of the relevant raw data to the Gnip XML meta-data to assist
66
+ Data Consumers so they do not need to proces the raw data payload at
67
+ all. In order to protect the integrity of the Gnip XML, it is gzip'd and
68
+ base64 encoded in the <raw> element. Data Consumers are responsible for
69
+ decoding and un-gzip'ing the raw element if they need the original data
70
+ (this can be easily done with the Gnip Convenience Libraries
71
+ <http://github.com/gnip>).
72
+
73
+
74
+ It is important to note that Data Consumers also have two options on how
75
+ to receive data, either by a *subscription*, which represents the entire
76
+ publisher "*firehose*" or by *filtering*, which represents specific
77
+ views of a publisher data stream. Data Consumers can create filters
78
+ <#Filter_terminology> for a specific publisher for either
79
+ *notifications* or *activities*.
80
+
81
+ * A *Firehose, *also sometimes called a *Public Timeline*, is the
82
+ stream of all the activities from a given Publisher. (Note: not
83
+ all Publishers support Public Timelines, and Public Timelines do
84
+ not always contain full data.) To avoid Publisher name clashes
85
+ and to show which publishers are 'bless and endorsed by Gnip",
86
+ Publisher's are namespace scoped to either "gnip," "my," (private
87
+ only to the Gnip account creator) or "public" (not supported at
88
+ present). Public Timelines can be "polled" (HTTP GET) from Gnip.
89
+ If you wish to have data pushed to you, you will need to create a
90
+ *Filter*.
91
+ * A *Filter* is a stream containing all the activities or
92
+ notifications that meet a set of defined criteria, called *rules,
93
+ *that are defined by the Data Consumer. For example, Filters allow
94
+ Data Consumers to create data streams containing just the
95
+ information from the Publisher based on users they are interested
96
+ in (using Gnip *rule-type "actor"*), or all the data from
97
+ Publisher "foo," that are tagged with a given string (using the
98
+ Gnip *rule-type* *"tag"*). When a Data Consumer creates a Filter
99
+ they are the only one who is granted access to use the filter.
100
+ Filters can be "polled" (HTTP GET) from a Gnip generated
101
+ end-point, or "pushed" (HTTP POST) to a Data Consumer POST URL
102
+ endpoint that is defined in the Filter.
103
+
104
+
105
+ In addition to the two approaches for defining data data consumption
106
+ (see a Data Consumer example for more details
107
+ <#Retrieve_recent_Activities_for_a_given_Publisher>), companies also can
108
+ *publish* data into the Gnip Platform by mapping an existing data source
109
+ to the Gnip XML schema. Here is an example of how to publish data
110
+ <#Examples_for_Publishers> to the Gnip Platform.
111
+
112
+
113
+ ------------------------------------------------------------------------
114
+
115
+
116
+ Overview of the Gnip Platform
117
+
118
+ <note: Andrew to add publisher and filter creation visuals for API use
119
+ case and web app use case>
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+ ------------------------------------------------------------------------
128
+
129
+
130
+ Gnip API Usage Information
131
+
132
+ * Before you can do anything you will need an account. You can
133
+ create one here <https://demo-v21.gnip.com/> in seconds.
134
+ * All requests to Gnip must be made over HTTPS (HTTP over SSL/TLS).
135
+ * The following examples assume you're sending HTTP BASIC AUTH'd
136
+ requests to https://demo-v21.gnip.com
137
+ * There are a variety of convenience libraries for many popular
138
+ languages provided by Gnip to ease your integration. You can find
139
+ them here. <http://github.com/gnip>
140
+ * The current list of Gnip Certified Publishers can be found here
141
+ <https://demo-v21.gnip.com/publishers.html>.
142
+ * Gnip's XML schema can be found here
143
+ <https://demo-v21.gnip.com/schema/gnip.xsd>.
144
+ * Gnip Activity & Notification access
145
+ o To access activities, use the "/*activity*/" endpoint.
146
+ o To access notifications, use the "/*notification*/" endpoint.
147
+ o Individual filters support only one endpoint type
148
+ ("activity" or "notification"); not both.
149
+ o You can not access the directly access the activity endpoint
150
+ of a publisher for which you are not the owner *unless* you
151
+ create a filter.
152
+
153
+
154
+ Examples
155
+
156
+
157
+ *Examples of Gnip Activities*
158
+
159
+ The examples below are broken into Data Consumer and Publisher sections.
160
+
161
+ Most users of Gnip are Data Consumers, but depending on the application,
162
+ a user may be a Data Consumer, a Publisher, or both. Both Publishers
163
+ and Data Consumers need to be familiar with Gnip activities which are
164
+ individually represented by an <activity/> document and collections
165
+ of <activity/> documents are wrapped in <activities/> documents. Below
166
+ are examples of each; the first example represents a
167
+ "notification"-style activity that does not contain the activity's
168
+ "full-data (payload)". Second is a "full-data" <activities/> document
169
+ example. Documents like these are emitted by both a Publisher's
170
+ notification stream as well as a Filter's notification and activity streams.
171
+
172
+
173
+ Sample of a Gnip Activity XML* for notifications
174
+ (.../notification/...)*
175
+
176
+ <activities publisher="gnip-sample">
177
+ <activity>
178
+ <at>2009-02-02T17:05:01.000Z</at>
179
+ <action>post</action>
180
+ <activityID>0.33783490478</activityID>
181
+ <URL>http://gnipherald.com/stories/0.33783490478/jousting-gone-bad.xml</URL>
182
+ <source>Vignette-Web-Publisher</source>
183
+ <place>
184
+ <point>38.2638886 -106.126131</point>
185
+ <featurename>Chloride Mine</featurename>
186
+ </place>
187
+ <actor uid="12339948@4994" metaURL="http://gnipherald.com/profiles/jvaleski">jvaleski</actor>
188
+ <destinationURL>http://gnipherald.com/stories/0.33783490478/jousting-gone-bad.html</destinationURL>
189
+ <tag metaURL="http://gnipherald/about/tag/armor">armor</tag>
190
+ <tag metaURL="http://gnipherald/about/tag/staff">staff</tag>
191
+ <tag metaURL="http://gnipherald/about/tag/injury">injury</tag>
192
+ <to metaURL="http://gnipherald.com/profiles/barinek">barinek</to>
193
+ <regardingURL metaURL="http://apnewswire.com/jousting">http://apnewswire.com/jousting/accident.html</regardingURL>
194
+ </activity>
195
+ </activities>
196
+
197
+ *Sample of a Gnip Activity XML with full data enabled (.../activity/...)*
198
+
199
+ <activities publisher="gnip-sample">
200
+ <activity>
201
+ <at>2009-02-02T17:16:01.000Z</at>
202
+ <action>post</action>
203
+ <activityID>0.516958128858</activityID>
204
+ <URL>http://gnipherald.com/stories/0.516958128858/jousting-gone-bad.xml</URL>
205
+ <source>Vignette-Web-Publisher</source>
206
+ <place>
207
+ <point>38.2638886 -106.126131</point>
208
+ <featurename>Chloride Mine</featurename>
209
+ </place>
210
+ <actor uid="12339948@4994" metaURL="http://gnipherald.com/profiles/jvaleski">jvaleski</actor>
211
+ <destinationURL>http://gnipherald.com/stories/0.516958128858/jousting-gone-bad.html</destinationURL>
212
+ <tag metaURL="http://gnipherald/about/tag/armor">armor</tag>
213
+ <tag metaURL="http://gnipherald/about/tag/staff">staff</tag>
214
+ <tag metaURL="http://gnipherald/about/tag/injury">injury</tag>
215
+ <to metaURL="http://gnipherald.com/profiles/barinek">barinek</to>
216
+ <regardingURL metaURL="http://apnewswire.com/jousting">http://apnewswire.com/jousting/accident.html</regardingURL>
217
+ <payload>
218
+ <title>Jousting Event Went Awry</title>
219
+ <body> Two drunken guys, two jousting sticks, blindfolds and
220
+ running full bore down a hallway at each other, lead to a night in
221
+ hospital for two university students. One with chest injury the other
222
+ unharmed. REST of BODY </body>
223
+ <mediaURL>http://images.gnipherald.com/jousting-thumbnail.jpg</mediaURL>
224
+ <raw>base64 encoded gzip compressed binary</raw>
225
+ </payload>
226
+ </activity>
227
+ </activities>
228
+
229
+
230
+ Examples for Data Consumers
231
+
232
+
233
+ Retrieve recent Activities for a given Publisher
234
+
235
+ This requires having a prior knowledge of the Publisher ID, a Publisher
236
+ ID is usually just a commonly known name for the Publisher such as
237
+ Publisher ID for twitter is "twitter". (A current list of Publisher IDs
238
+ can be found here <https://demo-v21.gnip.com/publishers.html> --
239
+ requires a Gnip account). In order to retrieve recent activities for a
240
+ given Publisher (e.g. "*gnip-sample*"), construct a URL for the
241
+ Publisher of interest and perform a HTTP GET to retrieve the
242
+ |application/xml| representation of that activity stream; for details go
243
+ here <#Activity_Buckets>. You can only access activities without full
244
+ data, e.g. "notifications," for a Publisher's *Public* Timeline. If you
245
+ want *full data*, you need to create a Filter and access it that way;
246
+ for an example, go here <#Create_a_Filter_Example>. Publisher data is
247
+ *namespaced*, that is, the list of publishers listed on the Gnip API
248
+ site <https://demo-v21.gnip.com/> are scoped to "*gnip*". When you
249
+ create a publisher, they will be scoped to "*my*".
250
+
251
+
252
+ ===>
253
+ GET /gnip/publishers/gnip-sample/notification/current.xml
254
+ Accept: application/xml
255
+
256
+ <---
257
+ 200 OK
258
+ Content-Type: application/xml
259
+
260
+ <activities publisher="gnip-sample">
261
+ <activity>
262
+ <at>2009-02-02T17:05:01.000Z</at>
263
+ <action>post</action>
264
+ <activityID>0.33783490478</activityID>
265
+ <URL>http://gnipherald.com/stories/0.33783490478/jousting-gone-bad.xml</URL>
266
+ <source>Vignette-Web-Publisher</source>
267
+ <place>
268
+ <point>38.2638886 -106.126131</point>
269
+ <featurename>Chloride Mine</featurename>
270
+ </place>
271
+ <actor uid="12339948@4994" metaURL="http://gnipherald.com/profiles/jvaleski">jvaleski</actor>
272
+ <destinationURL>http://gnipherald.com/stories/0.33783490478/jousting-gone-bad.html</destinationURL>
273
+ <tag metaURL="http://gnipherald/about/tag/armor">armor</tag>
274
+ <tag metaURL="http://gnipherald/about/tag/staff">staff</tag>
275
+ <tag metaURL="http://gnipherald/about/tag/injury">injury</tag>
276
+ <to metaURL="http://gnipherald.com/profiles/barinek">barinek</to>
277
+ <regardingURL metaURL="http://apnewswire.com/jousting">http://apnewswire.com/jousting/accident.html</regardingURL>
278
+ </activity>
279
+ </activities>
280
+
281
+
282
+ Retrieve activity for a Publisher 'n' minutes ago (*up to 60
283
+ minutes in the past*)
284
+
285
+ If you are interested in a point in the past, relative to now, you will
286
+ need to determine what the difference is between you local clock and
287
+ Gnip’s clock, to minimize clock drift as a variable in making requests
288
+ for activities; for details go here <#Activity_Buckets>.
289
+
290
+
291
+ ===>
292
+
293
+ HEAD /
294
+
295
+ <---
296
+
297
+ 200 OK
298
+
299
+ Date: Mon, June 9 2008, 9:08:43
300
+
301
+
302
+ The returned |Date| header field can be used to figure the difference
303
+ between Gnip's clock and the local one. Once that is known, the activity
304
+ bucket ID for the time of interest can be calculated. Once the activity
305
+ bucket ID is known its URL can be constructed using the same format as
306
+ above, replacing "current" with an activity bucket ID (e.g.|
307
+ *200806090910*)|, and the data can be retrieved. See the below section
308
+ called "Activity Buckets <#Activity_Buckets>". The activity bucket ID is
309
+ represented in *UTC time*. Please note that the two buckets, current and
310
+ 0-1 minutes old contain a *variable* amount of data, that is, data will
311
+ continue to be added to the buckets until a full minute has passed.
312
+ Buckets that are from 1-2 minutes and older contain a *fixed* amount of
313
+ data.
314
+
315
+ |===>
316
+ GET /gnip//publishers/gnip-sample/notification/*200806090910*.xml
317
+ Accept: application/xml
318
+ <---
319
+ 200 OK
320
+ Content-Type: application/xml
321
+
322
+ |
323
+
324
+ <activities publisher="gnip-sample">
325
+ <activity>
326
+ <at>2009-02-02T17:05:01.000Z</at>
327
+ <action>post</action>
328
+ <activityID>0.33783490478</activityID>
329
+ <URL>http://gnipherald.com/stories/0.33783490478/jousting-gone-bad.xml</URL>
330
+ <source>Vignette-Web-Publisher</source>
331
+ <place>
332
+ <point>38.2638886 -106.126131</point>
333
+ <featurename>Chloride Mine</featurename>
334
+ </place>
335
+ <actor uid="12339948@4994" metaURL="http://gnipherald.com/profiles/jvaleski">jvaleski</actor>
336
+ <destinationURL>http://gnipherald.com/stories/0.33783490478/jousting-gone-bad.html</destinationURL>
337
+ <tag metaURL="http://gnipherald/about/tag/armor">armor</tag>
338
+ <tag metaURL="http://gnipherald/about/tag/staff">staff</tag>
339
+ <tag metaURL="http://gnipherald/about/tag/injury">injury</tag>
340
+ <to metaURL="http://gnipherald.com/profiles/barinek">barinek</to>
341
+ <regardingURL metaURL="http://apnewswire.com/jousting">http://apnewswire.com/jousting/accident.html</regardingURL>
342
+ </activity>
343
+ </activities>
344
+
345
+ *
346
+ Create a Filter and retrieve its Activity*
347
+
348
+ To create a Filter you need one, or more, "*rules*." Each Publisher has
349
+ a set of supported rule types which constrain the types of rules that
350
+ can be specified for a Filter in a Publisher. For example, if a
351
+ Publisher supports the rule types "Actor" and "To", a Filter can contain
352
+ rules of using those types but cannot contain rules of type
353
+ "RegardingURL", "Tag", and "Source". If a Filter is created with a rule
354
+ type that a Publisher does not support, the server will return a
355
+ response containing of an error message and error status code. Here
356
+ <https://demo-v21.gnip.com/publishers.html> is a list of Publishers. In
357
+ order to find out what rule types a publisher supports you can look here
358
+ <https://demo-v21.gnip.com/publishers.html>.
359
+
360
+
361
+ Send an HTTP POST request to create a Filter. For details go here
362
+ <#Filters_Details>.
363
+
364
+ |===>
365
+ POST /gnip/publishers/gnip-sample/filters.xml
366
+ Accept: application/xml
367
+ Content-Type: application/xml
368
+
369
+ <filter name="examplefilter" fullData="true">
370
+ <rule type="actor">jvaleski</rule>
371
+ <rule type="actor">ajackson</rule>
372
+ </filter>||
373
+ <---
374
+ 200 OK
375
+ Content-Type: application/xml
376
+
377
+ <result>Success</result>|
378
+
379
+ Once the Filter is created, accessing full-data activity associated with
380
+ it is similar to accessing Publishers' notifications. Note that since
381
+ fullData was specified as true in this example, the result will include
382
+ the activity payload, and you'll access it via the ".../activity/..."
383
+ URI. Trying to access the ".../notification/..." URI would generate a
384
+ "Not Authorized" error.
385
+
386
+ |===>
387
+ GET /gnip/publishers/gnip-sample/filters/examplefilter/activity/current.xml
388
+ Accept: application/xml
389
+ <---
390
+ 200 OK
391
+ Content-Type: application/xml
392
+
393
+ |<activities publisher="gnip-sample">
394
+ <activity>
395
+ <at>2009-02-02T17:16:01.000Z</at>
396
+ <action>post</action>
397
+ <activityID>0.516958128858</activityID>
398
+ <URL>http://gnipherald.com/stories/0.516958128858/jousting-gone-bad.xml</URL>
399
+ <source>Vignette-Web-Publisher</source>
400
+ <place>
401
+ <point>38.2638886 -106.126131</point>
402
+ <featurename>Chloride Mine</featurename>
403
+ </place>
404
+ <actor uid="12339948@4994" metaURL="http://gnipherald.com/profiles/jvaleski">jvaleski</actor>
405
+ <destinationURL>http://gnipherald.com/stories/0.516958128858/jousting-gone-bad.html</destinationURL>
406
+ <tag metaURL="http://gnipherald/about/tag/armor">armor</tag>
407
+ <tag metaURL="http://gnipherald/about/tag/staff">staff</tag>
408
+ <tag metaURL="http://gnipherald/about/tag/injury">injury</tag>
409
+ <to metaURL="http://gnipherald.com/profiles/barinek">barinek</to>
410
+ <regardingURL metaURL="http://apnewswire.com/jousting">http://apnewswire.com/jousting/accident.html</regardingURL>
411
+ <payload>
412
+ <title>Jousting Event Went Awry</title>
413
+ <body>Two drunken guys, two jousting sticks, blindfolds and running full bore down a hallway at each other, lead to a night in hospital for two university students. One with chest injury the other unharmed. REST of BODY</body>
414
+ <mediaURL>http://images.gnipherald.com/jousting-thumbnail.jpg</mediaURL>
415
+ <raw>base64 encoded gzip compressed binary</raw>
416
+ </payload>
417
+ </activity>
418
+ </activities>
419
+
420
+
421
+ Create a Filter and have its Activity POSTed to specified URL
422
+
423
+ Create a Filter as in the previous example and in addition specify a
424
+ postURL to which activities should be HTTP POSTed. Gnip validates the
425
+ URL by making a HEAD request to it, so ensure that the postURL responds
426
+ successfully to an HTTP HEAD request. For details go here
427
+ <#Filters_Details>.
428
+
429
+ |===>
430
+ POST /gnip/publishers/gnip-sample/filters.xml
431
+ Accept: application/xml
432
+ Content-Type: application/xml
433
+
434
+ <filter name="examplefilter" fullData="true">
435
+ <postURL>http://mysite.example/inbound-activity-handler.cgi</postURL>
436
+ <rule type="actor">jvaleski</rule>
437
+ <rule type="actor">ajackson</rule>
438
+ </filter>||
439
+ <---
440
+ 200 OK
441
+ Content-Type: application/xml
442
+
443
+ |<result>Success</result>
444
+
445
+ Once the Filter is created, any activity that matches rules in the
446
+ filter will be POSTed to the specified URL; see below for an example
447
+ HTTP exchange that occurs when sending activities to a postURL. Gnip
448
+ activity POSTing is currently fire-and-forget and does not interpret
449
+ HTTP response codes from the POST.
450
+
451
+ |===>
452
+ POST http://mysite.example/inbound-activity-handler.cgi
453
+ Content-Type: application/xml
454
+
455
+ ||
456
+
457
+ <?xml version="1.0" encoding="utf-16"?>
458
+ <activities publisher="gnip-sample">
459
+ <activity>
460
+ <at>2009-02-02T17:16:01.000Z</at>
461
+ <action>post</action>
462
+ <activityID>0.516958128858</activityID>
463
+ <URL>http://gnipherald.com/stories/0.516958128858/jousting-gone-bad.xml</URL>
464
+ <source>Vignette-Web-Publisher</source>
465
+ <place>
466
+ <point>38.2638886 -106.126131</point>
467
+ <featurename>Chloride Mine</featurename>
468
+ </place>
469
+ <actor uid="12339948@4994" metaURL="http://gnipherald.com/profiles/jvaleski">jvaleski</actor>
470
+ <destinationURL>http://gnipherald.com/stories/0.516958128858/jousting-gone-bad.html</destinationURL>
471
+ <tag metaURL="http://gnipherald/about/tag/armor">armor</tag>
472
+ <tag metaURL="http://gnipherald/about/tag/staff">staff</tag>
473
+ <tag metaURL="http://gnipherald/about/tag/injury">injury</tag>
474
+ <to metaURL="http://gnipherald.com/profiles/barinek">barinek</to>
475
+ <regardingURL metaURL="http://apnewswire.com/jousting">http://apnewswire.com/jousting/accident.html</regardingURL>
476
+ <payload>
477
+ <title>Jousting Event Went Awry</title>
478
+ <body>Two drunken guys, two jousting sticks, blindfolds and running full bore down a hallway at each other, lead to a night in hospital for two university students. One with chest injury the other unharmed. REST of BODY</body>
479
+ <mediaURL>http://images.gnipherald.com/jousting-thumbnail.jpg</mediaURL>
480
+ <raw>base64 encoded gzip compressed binary</raw>
481
+ </payload>
482
+ </activity>
483
+ </activities>
484
+
485
+ <---
486
+ 200 OK
487
+ |
488
+
489
+ A note on authentication: Gnip does not support a Filter owner
490
+ specifying credentials to use on requests that post activities to a
491
+ Filter's postURL. As an interim solution, a Filter owner can provide an
492
+ opaque token on the postURL as part of the URL string. If this token is
493
+ only known to Gnip and the postURL's server, it can be validated on your
494
+ server when Gnip sends activities to a postURL to ensure that POST
495
+ requests originate from Gnip.
496
+
497
+
498
+ Examples for Publishers
499
+
500
+
501
+ Publish Activities to an Activity Stream
502
+
503
+ If you are a Publisher interested in publishing Activities to an
504
+ Activity Stream, POST application/xml to a Publisher created by you in
505
+ the following example. For details go here
506
+ <#Activity_Stream_Publishing>. Required fields are:
507
+
508
+ *<at>*
509
+
510
+ *<action>*
511
+
512
+
513
+ If a payload is added you must also include:
514
+
515
+ *<raw>*
516
+
517
+
518
+ The supported Gnip rule types are:
519
+
520
+ *actor*
521
+
522
+ *tag*
523
+
524
+ *to*
525
+
526
+ *regarding*
527
+
528
+ *source*
529
+
530
+
531
+ If you support one or more of the above rule types, the field for that
532
+ type is required.
533
+
534
+
535
+ ===>
536
+
537
+ | |POST /my/publishers/PUBLISHER-NAME/activity.xml
538
+
539
+ | |Accept: application/xml
540
+
541
+ | |Content-Type: application/xml
542
+
543
+ <activities publisher="gnip-sample">
544
+ <activity>
545
+ <at>2009-02-02T17:16:01.000Z</at>
546
+ <action>post</action>
547
+ <activityID>0.516958128858</activityID>
548
+ <URL>http://gnipherald.com/stories/0.516958128858/jousting-gone-bad.xml</URL>
549
+ <source>Vignette-Web-Publisher</source>
550
+ <place>
551
+ <point>38.2638886 -106.126131</point>
552
+ <featurename>Chloride Mine</featurename>
553
+ </place>
554
+ <actor uid="12339948@4994" metaURL="http://gnipherald.com/profiles/jvaleski">jvaleski</actor>
555
+ <destinationURL>http://gnipherald.com/stories/0.516958128858/jousting-gone-bad.html</destinationURL>
556
+ <tag metaURL="http://gnipherald/about/tag/armor">armor</tag>
557
+ <tag metaURL="http://gnipherald/about/tag/staff">staff</tag>
558
+ <tag metaURL="http://gnipherald/about/tag/injury">injury</tag>
559
+ <to metaURL="http://gnipherald.com/profiles/barinek">barinek</to>
560
+ <regardingURL metaURL="http://apnewswire.com/jousting">http://apnewswire.com/jousting/accident.html</regardingURL>
561
+ <payload>
562
+ <title>Jousting Event Went Awry</title>
563
+ <body> Two drunken guys, two jousting sticks, blindfolds and running full bore down a hallway at each other, lead to a night in hospital for two university students. One with chest injury the other unharmed. REST of BODY </body>
564
+ <mediaURL>http://images.gnipherald.com/jousting-thumbnail.jpg</mediaURL>
565
+ <raw>base64 encoded gzip compressed binary</raw>
566
+ </payload>
567
+ </activity>
568
+ </activities>
569
+
570
+ <---
571
+
572
+ 200 OK
573
+
574
+ | |Content-Type: application/xml
575
+
576
+
577
+ | <result>Success</result>|
578
+
579
+
580
+
581
+ ------------------------------------------------------------------------
582
+
583
+
584
+ Platform Capabilities and Terminology
585
+
586
+
587
+ *Response Codes
588
+
589
+ *
590
+
591
+ * Typical HTTP response codes are used throughout the API. A list
592
+ of HTTP response codes is here.
593
+ <http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html>
594
+ * Requests that do not need to return data or have failed return an
595
+ XML document describing the result of the request.
596
+
597
+
598
+ Activity Streams
599
+
600
+ Activity streams are collections of activities which may be retrieved
601
+ and, in some situations, to which activities may be published.
602
+ Publishers POST new activities to activity streams; they are the start
603
+ of data flow through the system. Subscribers can retrieve activity data
604
+ via activity buckets (see the Activity Buckets <#Activity_Buckets>
605
+ section below).
606
+
607
+
608
+ *https://demo-v21.gnip.com/my[gnip]/publishers/PUBLISHER-NAME/activity[notification].xml*
609
+
610
+ |
611
+ (Replace PUBLISHER-NAME with the name of an actual publisher. The list
612
+ of current Publishers can be found here
613
+ <https://demo-v21.gnip.com/publishers.html>)|
614
+
615
+ GET:
616
+ Returns an XML representation (Activity Stream XML
617
+ <#Activity_Stream_XML>) of the activity Publisher activity stream.
618
+ Response Content-Type: application/xml
619
+
620
+
621
+ Activity Stream XML
622
+
623
+ An activity stream represented in XML looks like the following. Full
624
+ Gnip XML schema can be found here
625
+ <https://demo-v21.gnip.com/schema/gnip.xsd>.
626
+
627
+ <?xml version="1.0" encoding="utf-16"?>
628
+ <activityStream>
629
+ <activitiesAddedAt>2008-07-28T11:32:50Z</activitiesAddedAt>
630
+ <buckets>
631
+ <bucket href="/my[gnip]/publishers/PUBLISHER-NAME/activity/200807281130.xml" />
632
+ <bucket href="/my[gnip]/publishers/PUBLISHER-NAME/activity/200807281125.xml" />
633
+ <bucket href="/my[gnip]publishers/PUBLISHER-NAME/activity/200807281130.xml" />
634
+ <!-- ... -->
635
+ </buckets>
636
+ </activityStream>
637
+
638
+
639
+ Activity Buckets
640
+
641
+ Activity streams are segmented into buckets based on time. Each bucket
642
+ contains all the activities for the stream that are reported during the
643
+ bucket’s duration. Each bucket has an ID that is the time stamp, in UTC,
644
+ of the first minute bucket. The bucket ID format is |%Y%m%d%H%M%S| (e.g.
645
+ the strftime conversion spec). For example, bucket with ID
646
+ |200806090913| would contain all activity reported during between 9:13
647
+ am and 9:14 UTC am, inclusive, on June 9, 2008. Activity buckets are
648
+ only valid for the last 60 minutes. The "current.xml" bucket holds the
649
+ "current" activities up to one minute. Please note that the current
650
+ bucket is not static, so retrieving data from this bucket may not be
651
+ reliable for your application. The same goes for the 0-1 minute old
652
+ bucket. Until the full minute is up, the bucket will continue to accrue
653
+ data.
654
+
655
+
656
+ *https://demo-v21.gnip.com/my[gnip]/publishers/PUBLISHER-NAME/notification/current.xml
657
+ **https://demo-v21.gnip.com/my[gnip]/publishers/PUBLISHER-NAME/notification/BUCKET-ID.xml
658
+ *
659
+ *https://demo-v21.gnip.com/my[gnip]*/publishers/**PUBLISHER-NAME/**filters/FILTER-NAME/activity**[notification]**/current.xml**
660
+
661
+ *https://demo-v21.gnip.com/my[gnip]*/publishers/**PUBLISHER-NAME/**filters/FILTER-NAME/activity**[notification]**/BUCKET-ID.xml**
662
+
663
+
664
+
665
+ GET:
666
+ Returns a representation (Activities XML <#Activities_XML>) of the
667
+ activity bucket specified.
668
+ Response Content-Type: application/xml
669
+
670
+
671
+ Activities XML
672
+
673
+
674
+ Activity definitions are represented as XML documents similar to this.
675
+
676
+
677
+ <activities publisher="gnip-sample">
678
+ <activity>
679
+ <at>2009-02-02T17:16:01.000Z</at>
680
+ <action>post</action>
681
+ <activityID>0.516958128858</activityID>
682
+ <URL>http://gnipherald.com/stories/0.516958128858/jousting-gone-bad.xml</URL>
683
+ <source>Vignette-Web-Publisher</source>
684
+ <place>
685
+ <point>38.2638886 -106.126131</point>
686
+ <featurename>Chloride Mine</featurename>
687
+ </place>
688
+ <actor uid="12339948@4994" metaURL="http://gnipherald.com/profiles/jvaleski">jvaleski</actor>
689
+ <destinationURL>http://gnipherald.com/stories/0.516958128858/jousting-gone-bad.html</destinationURL>
690
+ <tag metaURL="http://gnipherald/about/tag/armor">armor</tag>
691
+ <tag metaURL="http://gnipherald/about/tag/staff">staff</tag>
692
+ <tag metaURL="http://gnipherald/about/tag/injury">injury</tag>
693
+ <to metaURL="http://gnipherald.com/profiles/barinek">barinek</to>
694
+ <regardingURL metaURL="http://apnewswire.com/jousting">http://apnewswire.com/jousting/accident.html</regardingURL>
695
+ <payload>
696
+ <title>Jousting Event Went Awry</title>
697
+ <body> Two drunken guys, two jousting sticks, blindfolds and
698
+ running full bore down a hallway at each other, lead to a night in
699
+ hospital for two university students. One with chest injury the other
700
+ unharmed. REST of BODY </body>
701
+ <mediaURL>http://images.gnipherald.com/jousting-thumbnail.jpg</mediaURL>
702
+ <raw>base64 encoded gzip compressed binary</raw>
703
+ </payload>
704
+ </activity>
705
+ </activities>
706
+
707
+
708
+ Activity XML document conform to the following schema. Full Gnip XML
709
+ schema can be found here <https://demo-v21.gnip.com/schema/gnip.xsd>.
710
+
711
+
712
+ ||
713
+
714
+ ...
715
+
716
+ <xs:element name="activity">
717
+ <xs:complexType>
718
+ <xs:sequence>
719
+ <xs:element name="at" type="xs:dateTime" minOccurs="1" maxOccurs="1" />
720
+ <xs:element name="action" type="xs:string" minOccurs="1" maxOccurs="1" />
721
+ <xs:element name="activityID" type="xs:string" minOccurs="0" maxOccurs="1" />
722
+ <xs:element name="URL" type="xs:anyURI" minOccurs="0" maxOccurs="1" />
723
+ <xs:element name="source" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
724
+ <xs:element name="keyword" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
725
+ <xs:element name="place" minOccurs="0" maxOccurs="unbounded">
726
+ <xs:complexType>
727
+ <xs:sequence>
728
+ <xs:element name="point" type="pointType" minOccurs="0" maxOccurs="1" />
729
+ <xs:element name="elev" type="xs:double" minOccurs="0" maxOccurs="1" />
730
+ <xs:element name="floor" type="xs:integer" minOccurs="0" maxOccurs="1" />
731
+ <xs:element name="featuretypetag" type="xs:string" minOccurs="0" maxOccurs="1" />
732
+ <xs:element name="featurename" type="xs:string" minOccurs="0" maxOccurs="1" />
733
+ <xs:element name="relationshiptag" type="xs:string" minOccurs="0" maxOccurs="1" />
734
+ </xs:sequence>
735
+ </xs:complexType>
736
+ </xs:element>
737
+ <xs:element name="actor" minOccurs="0" maxOccurs="unbounded">
738
+ <xs:complexType>
739
+ <xs:simpleContent>
740
+ <xs:extension base="xs:string">
741
+ <xs:attribute name="metaURL" use="optional" type="xs:anyURI" />
742
+ <xs:attribute name="uid" use="optional" type="xs:string" />
743
+ </xs:extension>
744
+ </xs:simpleContent>
745
+ </xs:complexType>
746
+ </xs:element>
747
+ <xs:element name="destinationURL" minOccurs="0" maxOccurs="unbounded">
748
+ <xs:complexType>
749
+ <xs:simpleContent>
750
+ <xs:extension base="xs:anyURI">
751
+ <xs:attribute name="metaURL" use="optional" type="xs:anyURI" />
752
+ </xs:extension>
753
+ </xs:simpleContent>
754
+ </xs:complexType>
755
+ </xs:element>
756
+ <xs:element name="tag" minOccurs="0" maxOccurs="unbounded">
757
+ <xs:complexType>
758
+ <xs:simpleContent>
759
+ <xs:extension base="xs:string">
760
+ <xs:attribute name="metaURL" use="optional" type="xs:anyURI" />
761
+ </xs:extension>
762
+ </xs:simpleContent>
763
+ </xs:complexType>
764
+ </xs:element>
765
+ <xs:element name="to" minOccurs="0" maxOccurs="unbounded">
766
+ <xs:complexType>
767
+ <xs:simpleContent>
768
+ <xs:extension base="xs:string">
769
+ <xs:attribute name="metaURL" use="optional" type="xs:anyURI" />
770
+ </xs:extension>
771
+ </xs:simpleContent>
772
+ </xs:complexType>
773
+ </xs:element>
774
+ <xs:element name="regardingURL" minOccurs="0" maxOccurs="unbounded">
775
+ <xs:complexType>
776
+ <xs:simpleContent>
777
+ <xs:extension base="xs:anyURI">
778
+ <xs:attribute name="metaURL" use="optional" type="xs:anyURI" />
779
+ </xs:extension>
780
+ </xs:simpleContent>
781
+ </xs:complexType>
782
+ </xs:element>
783
+ <xs:element name="payload" minOccurs="0" maxOccurs="1">
784
+ <xs:complexType>
785
+ <xs:sequence>
786
+ <xs:element name="title" type="xs:string" minOccurs="0" maxOccurs="1" />
787
+ <xs:element name="body" type="xs:normalizedString" minOccurs="0" maxOccurs="1" />
788
+ <xs:element name="mediaURL" minOccurs="0" maxOccurs="unbounded">
789
+ <xs:complexType>
790
+ <xs:simpleContent>
791
+ <xs:extension base="xs:anyURI">
792
+ <xs:attribute name="height" use="optional" type="xs:string" />
793
+ <xs:attribute name="width" use="optional" type="xs:string" />
794
+ <xs:attribute name="duration" use="optional" type="xs:string" />
795
+ <xs:attribute name="mimeType" use="optional" type="xs:string" />
796
+ <xs:attribute name="type" use="optional" type="xs:string" />
797
+ </xs:extension>
798
+ </xs:simpleContent>
799
+ </xs:complexType>
800
+ </xs:element>
801
+ <xs:element name="raw" type="xs:base64Binary" minOccurs="1" maxOccurs="1" />
802
+ </xs:sequence>
803
+ </xs:complexType>
804
+ </xs:element>
805
+ </xs:sequence>
806
+ </xs:complexType>
807
+ </xs:element>
808
+ ...
809
+ </xs:schema>
810
+
811
+
812
+ *Filters*
813
+
814
+ A Filter consists of rules that are used to match activities flowing
815
+ through a Publisher's activity stream. Filters may be created, edited,
816
+ and deleted at will by their owner. Filter rules are OR'd together;
817
+ there is no AND support. Since your filter is created on a per publisher
818
+ basis, the URI will reflect the namespace of that publisher ("my" or
819
+ "gnip").
820
+
821
+
822
+ If a Filter specifies a postURL, new activities that meet the collection
823
+ criteria will be posted to the specified URL. POSTed activities include
824
+ *full data* by default.
825
+
826
+
827
+ *https://demo-v21.gnip.com/my[gnip]/publishers/PUBLISHER-NAME/filters.xml*
828
+
829
+ GET:
830
+ Returns the Filters XML document which lists all the filters,
831
+ including their rules, you own for the specified Publisher.
832
+ Response Content-Type: application/xml
833
+
834
+ POST:
835
+ Accepts a Filter XML document and creates a new filter based on that
836
+ information. If your Filter document is large it should be gzip'd, and
837
+ sent with the "Content-Encoding: gzip" header. If you wish to update a
838
+ filter, use PUT, described below. POSTing a Filter twice with the same
839
+ name will result in an error response from the server.
840
+ Request Content-Type: application/xml
841
+ Response Content-Type: application/xml
842
+
843
+ *https://demo-v21.gnip.com/my[gnip]/publishers/PUBLISHER-NAME/filters/FILTER-NAME.xml*
844
+
845
+ GET:
846
+ Returns a Filter XML representation of the specified Filter.
847
+ Response Content-Type: application/xml
848
+ PUT:
849
+ Accepts a Filter XML document and updates the specified Filter to match
850
+ the data provided. Gnip will replace the existing Filter with this
851
+ document. If you're trying to create a Filter for the first time, use
852
+ POST, described above. For incremental updates of a Filter, see the next
853
+ section "Editing Filter Rules."
854
+ Request Content-Type: application/xml
855
+ Response Content-Type: application/xml
856
+ DELETE:
857
+ Removes the specified Filter.
858
+
859
+ *Filter** XML*
860
+
861
+
862
+ Filter definitions are represented as XML documents similar to this.
863
+
864
+
865
+ |<filter name="example" fullData="true|false">
866
+ <postURL>optional</postURL>
867
+ <rule type="actor">joe</rule>
868
+ <rule type="tag">cars</rule>
869
+ </filter>
870
+ |
871
+
872
+
873
+
874
+
875
+ Filter XML document conform to the following schema. Full Gnip XML
876
+ schema can be found here <https://demo-v21.gnip.com/schema/gnip.xsd>.
877
+
878
+
879
+ <xs:element name="filter">
880
+ <xs:complexType>
881
+ <xs:sequence>
882
+ <xs:element name="postURL" type="xs:anyURI" minOccurs="0" maxOccurs="1" />
883
+ <xs:element name="rule" type="rule" maxOccurs="unbounded" minOccurs="1" />
884
+ </xs:sequence>
885
+ <xs:attribute name="name" type="uriSafeType" use="required" />
886
+ <xs:attribute name="fullData" type="xs:boolean" use="required" />
887
+ </xs:complexType>
888
+ </xs:element>
889
+
890
+
891
+ *Editing Filter Rules*
892
+
893
+ A Filter's rule set can be incrementally updated and queried via the
894
+ Filter's /rules endpoint. The rules endpoint can be used to add a
895
+ single rule or to batch add a set of rules. The rules endpoint is
896
+ namespaced based on the Publisher scope (either "my" or "gnip").
897
+
898
+ Each publisher supports a different set of one or more rules. To review
899
+ the list of supported rule types, you can view the schema document
900
+ <https://demo-v21.gnip.com/schema/gnip.xsd>. Currently, the types are:
901
+
902
+ *actor*
903
+
904
+ *tag*
905
+
906
+ *to*
907
+
908
+ *regarding*
909
+
910
+ *source*
911
+
912
+
913
+ To find out if a publisher supports the rule types, you can look at the
914
+ list of Publishers, the action types they support, and example XML
915
+ output <http://gnip-community.googlegroups.com/web/publishers.html>.
916
+
917
+
918
+ *
919
+ https://demo-v21.gnip.com/my[gnip]/publishers/PUBLISHER-NAME/filters/FILTER-NAME/rules
920
+ *
921
+ GET:
922
+ Accepts a query string consisting of a single rule to search for
923
+ in the Filter named FILTER-NAME.
924
+ For example:
925
+ .../my[gnip]/publishers/PUBLISHER-NAME/filters/FILTER-NAME/rules?type=actor&value=joe
926
+ Request Content-Type: *
927
+ Response Content-Type: application/xml
928
+ Response Codes:
929
+ 200: if the rule is found in the Filter. The response body
930
+ will contain the XML of found <rule/>.
931
+ 404: if the rule could not be found.
932
+ POST:
933
+ Accepts two XML document types:
934
+ Send a rule XML document (e.g. <rule type="">value</rule> )
935
+ to add a single rule to FILTER-NAME.
936
+ Send a rules XML document (e.g. <rules>...</rules>) that
937
+ wraps one or more <rule/> documents to batch add to FILTER-NAME.
938
+ For example:
939
+ .../my[gnip]/publishers/PUBLISHER-NAME/filters/FILTER-NAME/rules.xml
940
+ Request Content-Type: application/xml
941
+ Response Content-Type: application/xml
942
+ Response Codes:
943
+ 200: if an individual rule is successfully added to the
944
+ Filter.
945
+ if sending a <rules/> document, a 200 will be
946
+ returned if the document is successfully received, but the server
947
+ processes a batch update asynchronously, so for <rules/> a 200 does not
948
+ imply that they have been added to the Filter. Use either the rules/
949
+ endpoint to search for a newly added rule or a GET on the whole Filter
950
+ to ensure all rules in the batch were added.
951
+ 400: if adding a <rule/> with a rule type that isn't
952
+ supported by the publisher
953
+
954
+ DELETE:
955
+ Accepts a query string consisting of a *single* rule to be removed from
956
+ FILTER-NAME.
957
+ For example:
958
+ .../my[gnip]/publishers/PUBLISHER-NAME/filters/FILTER-NAME/rules?type=actor&value=joe
959
+ Request Content-Type: *
960
+ Response Content-Type: *
961
+
962
+ *Large Filters and the rules endpoint
963
+
964
+ *When using filters on the Gnip Platform, the rule sets can grow "large"
965
+ and have tens and hundreds of thousands (or more) rules used to match
966
+ specific types of activities from a given Publisher. In the case of
967
+ large rule sets, the rule endpoint *must *be used to add rules to a
968
+ large Filter due to the fact that making incremental changes by GETting,
969
+ changing, and POSTing the entire <filter/> XML document causes a
970
+ needless exchange of many megabytes of data. Instead, large Filters can
971
+ be incrementally augmented by sending batches of up to
972
+ 5000 <rule/> documents wrapped inside a <rules/> document to
973
+ the rules/ endpoint. For example, to add 100,000 rules to a Filter that
974
+ has an existing 100,000 rules, send 20 <rules/> documents containing
975
+ 5000 rules each rather than sending 100,000
976
+ individual <rule/> documents to the rules/ endpoint (which could take
977
+ days) or than sending a PUT of the Filter containing 200,000 rules
978
+ (which unnecessarily transmits large amounts of repetitive rules).
979
+
980
+ POST:
981
+ Accepts two XML document types:
982
+ Send a rules XML document (e.g. <rules>...</rules>) that
983
+ wraps one or more <rule/> documents to batch add to FILTER-NAME.
984
+ For
985
+ example: .../my[gnip]/publishers/PUBLISHER-NAME/filters/FILTER-NAME/rules.xml
986
+ Request Content-Type: application/xml
987
+ Response Content-Type: application/xml
988
+ Response Codes:
989
+ 200: If the document is successfully received, but the
990
+ server processes a batch update asynchronously. A 200 does not imply
991
+ that the rules have been added to the Filter. Use either the rules/
992
+ endpoint to search for a newly added rule or a GET on the whole Filter
993
+ to ensure all rules in the batch were added.
994
+ 400: if adding a <rule/> with a rule type that isn't
995
+ supported by the publisher
996
+
997
+ *Publishers
998
+
999
+ *
1000
+
1001
+ Publishers are scoped to either be "system-wide" and publicly available
1002
+ (e.g. in the "gnip" namespace), or privately scoped in the "my"
1003
+ namespace. A current list of public Publishers in the Gnip system can be
1004
+ found here <https://demo-v21.gnip.com/publishers.html>. They are owned
1005
+ by a single account and only that account can manipulate the publisher
1006
+ definition and publish activities to its activity stream. A Publisher
1007
+ can move their private "my" Publisher feed to a GNIP endorsed by
1008
+ contacting GNIP.
1009
+
1010
+
1011
+ *https://demo-v21.gnip.com/my[gnip]/publishers.xml*
1012
+
1013
+ * *
1014
+ Different actions can be done by doing a get, post or a delete to the
1015
+ URL above*.*
1016
+
1017
+ *Retrieve a list of publishers:
1018
+ * GET:
1019
+ Returns a Publisher XML document listing of current Publisher's in
1020
+ the system. Use "gnip" in the URL to return the list of endorsed
1021
+ publicly available publishers and "my" to return your list of publishers.
1022
+ Response Content-Type: application/xml
1023
+
1024
+ *To create a new publisher:*
1025
+ POST:
1026
+ Accepts a Publisher XML <#Publisher_XML> document and creates a new
1027
+ publisher using that information. Post can only be done to the ".../my"
1028
+ scope. Only GNIP can create GNIP publishers.
1029
+ Request Content-type: application/xml
1030
+ Response Content-Type: application/xml
1031
+
1032
+ *To delete a publisher you own:*
1033
+ DELETE:
1034
+ Accepts a query string consisting of a single pubisher to be
1035
+ removed using my for scope. Only GNIP can delete gnip publishers.
1036
+ For example: .../my/publishers/PUBLISHER-NAME
1037
+ Request Content-Type: *
1038
+ Response Content-Type: *
1039
+
1040
+
1041
+ Publisher XML
1042
+
1043
+ Publisher definitions are represented as XML documents similar to this.
1044
+ As a Publisher you can define which rules you support. Rule types today
1045
+ are: actor, tag, to, regarding and source. Below is an example of XML
1046
+ that has actor as supported.
1047
+
1048
+
1049
+ <publisher name="gnip-sample">
1050
+ <supportedRuleTypes>
1051
+ <type>actor</type>
1052
+ </supportedRuleTypes>
1053
+ </publisher>
1054
+
1055
+ Publisher XML document conform to the following schema. Full Gnip XML
1056
+ schema can be found here <https://demo-v21.gnip.com/schema/gnip.xsd>.
1057
+
1058
+
1059
+ ...
1060
+ <xs:element name="publisher">
1061
+ <xs:complexType>
1062
+ <xs:sequence>
1063
+ <xs:element name="supportedRuleTypes" minOccurs="1" maxOccurs="1">
1064
+ <xs:complexType>
1065
+ <xs:sequence>
1066
+ <xs:element name="type" type="ruleType" minOccurs="1" maxOccurs="unbounded" />
1067
+ </xs:sequence>
1068
+ </xs:complexType>
1069
+ </xs:element>
1070
+ </xs:sequence>
1071
+ <xs:attribute name="name" type="uriSafeType" use="required" />
1072
+ </xs:complexType>
1073
+ </xs:element>
1074
+ ...
1075
+
1076
+
1077
+ *Push Recipients
1078
+ *
1079
+
1080
+ Filters can be subscribed to in such a way that any time activities are
1081
+ published that match the Filter criteria, those activities are pushed,
1082
+ via a HTTP POST, to a configurable URL. The URL to which activities will
1083
+ be pushed is specified by the postURL of the Filter XML. Any activities
1084
+ added to a Filter which has a <postURL/>, will automatically be POSTed
1085
+ to that URL. The body of these POSTs will be an Activities XML document
1086
+ (described above in the Activity Buckets section <#Activity_Buckets>).
1087
+ Responses to these requests are ignored. PostURLs must be valid.
1088
+
1089
+
1090
+ *http://mysite.example/inbound-activity-handler.cgi
1091
+
1092
+ *
1093
+
1094
+ POST:
1095
+
1096
+ Pushes new activities, as an Activities XML <#Activities_XML> document,
1097
+ to the subcriber to this collection.
1098
+
1099
+ Request Content-Type: |application/xml|
1100
+
1101
+
1102
+ Activities XML
1103
+
1104
+ A set of activities are represented in XML documents that look like
1105
+ this. Full Gnip XML schema can be found here
1106
+ <https://demo-v21.gnip.com/schema/gnip.xsd>.
1107
+
1108
+ <?xml version="1.0" encoding="utf-16"?>
1109
+ <activities publisher="gnip-sample">
1110
+ <activity>
1111
+ <at>2009-02-02T17:16:01.000Z</at>
1112
+ <action>post</action>
1113
+ <activityID>0.516958128858</activityID>
1114
+ <URL>http://gnipherald.com/stories/0.516958128858/jousting-gone-bad.xml</URL>
1115
+ <source>Vignette-Web-Publisher</source>
1116
+ <place>
1117
+ <point>38.2638886 -106.126131</point>
1118
+ <featurename>Chloride Mine</featurename>
1119
+ </place>
1120
+ <actor uid="12339948@4994" metaURL="http://gnipherald.com/profiles/jvaleski">jvaleski</actor>
1121
+ <destinationURL>http://gnipherald.com/stories/0.516958128858/jousting-gone-bad.html</destinationURL>
1122
+ <tag metaURL="http://gnipherald/about/tag/armor">armor</tag>
1123
+ <tag metaURL="http://gnipherald/about/tag/staff">staff</tag>
1124
+ <tag metaURL="http://gnipherald/about/tag/injury">injury</tag>
1125
+ <to metaURL="http://gnipherald.com/profiles/barinek">barinek</to>
1126
+ <regardingURL metaURL="http://apnewswire.com/jousting">http://apnewswire.com/jousting/accident.html</regardingURL>
1127
+ <payload>
1128
+ <title>Jousting Event Went Awry</title>
1129
+ <body> Two drunken guys, two jousting sticks, blindfolds and running full bore down a hallway at each other, lead to a night in hospital for two university students. One with chest injury the other unharmed. REST of BODY </body>
1130
+ <mediaURL>http://images.gnipherald.com/jousting-thumbnail.jpg</mediaURL>
1131
+ <raw>base64 encoded gzip compressed binary</raw>
1132
+ </payload>
1133
+ </activity>
1134
+ </activities>
1135
+
1136
+
1137
+ Errors
1138
+
1139
+ In the event of Gnip being unable to fulfill a request it will return a
1140
+ response with the most appropriate response code and a human readable
1141
+ message in the body. If the request could not be fulfilled because
1142
+ there was something wrong with the request a 4xx series response code
1143
+ will be used. If the request was not fulfilled for any other reason a
1144
+ 5xx series response code will be used.
1145
+
1146
+ *Error XML*
1147
+
1148
+
1149
+ An error represented in XML looks like this:
1150
+
1151
+
1152
+ <error>"foo_bar" is not a valid publisher name. Only letter, number,
1153
+ '.', '+' and '-' characters are allowed in publisher names.</error>
1154
+
1155
+
1156
+ Remember, depending on your HTTP client, an <error/> message may only be
1157
+ available as part of an error input stream in the event that the server
1158
+ returns an HTTP response with a non-200 response code. For example, in
1159
+ the case of Java's java.net.HttpURLConnection, the <error/> message
1160
+ would be available via the getErrorStream() method.
1161
+
1162
+
1163
+ *Revision History*
1164
+
1165
+ * rev 12 - Update to delete URL endpoint
1166
+ * rev 11 - Changed Publishers and Subscribers to Data Producers and
1167
+ Data Consumers. Fixed URLs, added publishing to an activity, did
1168
+ color changes.
1169
+ * rev 10 - changed XML examples from gnipherald publisher to gnip-sample
1170
+ * rev 9 - updated xml examples to include final schema, added delete
1171
+ publisher example
1172
+ * rev 8 - minor editing tweaks
1173
+ * rev 7 - some minor editing tweaks
1174
+ * rev 6 - new schema, version 2.1
1175
+ * rev 5 - added documentation for batch and search support in the
1176
+ rules/ endpoint. Added documentation to the Activities section of
1177
+ the samples. Rearranged some links and made some XML formatting
1178
+ changes.
1179
+ * rev 4 - updated for publisher capabilities, added paragraph on
1180
+ authentication for activity push, remove references to JIDs,
1181
+ document cleanup
1182
+ * rev 3 - updating publisher activity endpoint to reflect the
1183
+ correct one.
1184
+ * rev 2 - added verbiage to further clarify filter management.
1185
+ * rev 1 - moved bucket-ID API from five minute buckets to single
1186
+ minute buckets
1187
+ * rev 0 - initial cut of the 2.0 document
1188
+
1189
+
1190
+
1191
+
1192
+
1193
+
1194
+
1195
+
1196
+ Edit this page (if you have permission)
1197
+ <Edit?tab=edit&dr=true&docid=dpw6zj9_0fdcnttgd> |
1198
+ Google Docs -- Web word processing, presentations and spreadsheets. </>
1199
+
1200
+
1201
+