rbmediawiki 0.2 → 0.2.1

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/lib/api.rb DELETED
@@ -1,922 +0,0 @@
1
- #coding: utf-8
2
- require 'yaml'
3
- require 'net/http'
4
- require 'rubygems'
5
- require 'xmlsimple'
6
-
7
- Ourconfig = YAML::load(File.open(File.dirname(__FILE__)+"/config.yml"))
8
-
9
- # This class provides an interface for the MediaWiki API.
10
- # Methods match specific queries to the API, and so the meaning of the
11
- # parameters are described in http://www.mediawiki.org/wiki/API
12
- #
13
- # It is intended to be used as a base layer to build specific methods on top
14
- # of it
15
- #
16
- # Only four methods are special and deserve comments here: #new, #login, #query and #add_post
17
-
18
- class Api
19
-
20
- # * lang: language of the wiki at wikimedia.
21
- # * family: family of the wiki at wikimedia. If the wiki is not language dependant, as commons.wikimedia.org , lang value is ignored.
22
- # * user: user to make the edits
23
- # * server: the url of the server, as in http://en.wikipedia.org this parameter overrides lang and family values
24
- # * api_url: the url of the api, as in http://en.wikipedia.org if not specified, it will be guessed from the lang+family values or the server
25
- def initialize(lang = nil, family = nil, user = nil, server = nil, api_url = nil)
26
- @config = Hash.new
27
- @config['base_url'] = server
28
- @config['api_url'] = api_url
29
- @config['logged'] = false
30
- @config['user'] = user ? user : Ourconfig['default_user']
31
- end
32
-
33
- def api_url
34
- return @config['api_url']
35
- end
36
-
37
- def base_url
38
- return @config['base_url']
39
- end
40
-
41
- #Asks for a password and tries to log in. Stores the resulting cookies
42
- #for using then when making requests. If the user is already logged iy
43
- #does nothing
44
-
45
- def login(password = nil)
46
- if @config['logged']
47
- return true
48
- end
49
- if (!password)
50
- puts "Introduce password for #{@config['user']} at #{@config['base_url']}"
51
- password = gets.chomp
52
- end
53
-
54
- post_me = add_post('lgname',@config['user'])
55
- post_me = add_post('lgpassword',password, post_me)
56
- post_me = add_post('action', 'login', post_me)
57
-
58
- login_result = make_request(post_me)
59
-
60
- @config['lgusername'] = login_result['login']['lgusername']
61
- @config['lguserid'] = login_result['login']['lguserid']
62
- @config['lgtoken'] = login_result['login']['lgtoken']
63
- @config['_session'] = login_result['login']['sessionid']
64
- @config['cookieprefix']= login_result['login']['cookieprefix']
65
-
66
- @config['logged'] = true
67
-
68
- return @cookie
69
- end
70
-
71
- def query_prop_categories(titles = nil, clprop = nil, clshow = nil, cllimit = nil, clcontinue = nil, clcategories = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
72
-
73
- post_me = add_post('clprop', clprop, post_me)
74
- post_me = add_post('clshow', clshow, post_me)
75
- post_me = add_post('cllimit', cllimit, post_me)
76
- post_me = add_post('clcontinue', clcontinue, post_me)
77
- post_me = add_post('clcategories', clcategories, post_me)
78
- post_me = add_post('prop', 'categories', post_me)
79
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
80
- post_me = format(post_me, 'xml')
81
- result = make_request(post_me)
82
- return result
83
- end
84
-
85
- def query_prop_images(titles = nil, imlimit = nil, imcontinue = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
86
-
87
- post_me = add_post('imlimit', imlimit, post_me)
88
- post_me = add_post('imcontinue', imcontinue, post_me)
89
- post_me = add_post('prop', 'images', post_me)
90
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
91
- post_me = format(post_me, 'xml')
92
- result = make_request(post_me)
93
- return result
94
- end
95
-
96
- def query_prop_revisions(titles = nil, rvprop = nil, rvlimit = nil, rvstartid = nil, rvendid = nil, rvstart = nil, rvend = nil, rvdir = nil, rvuser = nil, rvexcludeuser = nil, rvexpandtemplates = nil, rvgeneratexml = nil, rvsection = nil, rvtoken = nil, rvcontinue = nil, rvdiffto = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
97
-
98
- post_me = add_post('rvprop', rvprop, post_me)
99
- post_me = add_post('rvlimit', rvlimit, post_me)
100
- post_me = add_post('rvstartid', rvstartid, post_me)
101
- post_me = add_post('rvendid', rvendid, post_me)
102
- post_me = add_post('rvstart', rvstart, post_me)
103
- post_me = add_post('rvend', rvend, post_me)
104
- post_me = add_post('rvdir', rvdir, post_me)
105
- post_me = add_post('rvuser', rvuser, post_me)
106
- post_me = add_post('rvexcludeuser', rvexcludeuser, post_me)
107
- post_me = add_post('rvexpandtemplates', rvexpandtemplates, post_me)
108
- post_me = add_post('rvgeneratexml', rvgeneratexml, post_me)
109
- post_me = add_post('rvsection', rvsection, post_me)
110
- post_me = add_post('rvtoken', rvtoken, post_me)
111
- post_me = add_post('rvcontinue', rvcontinue, post_me)
112
- post_me = add_post('rvdiffto', rvdiffto, post_me)
113
- post_me = add_post('prop', 'revisions', post_me)
114
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
115
- post_me = format(post_me, 'xml')
116
- result = make_request(post_me)
117
- return result
118
- end
119
-
120
- def query_meta_siteinfo(titles = nil, siprop = nil, sifilteriw = nil, sishowalldb = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
121
-
122
- post_me = add_post('siprop', siprop, post_me)
123
- post_me = add_post('sifilteriw', sifilteriw, post_me)
124
- post_me = add_post('sishowalldb', sishowalldb, post_me)
125
- post_me = add_post('meta', 'siteinfo', post_me)
126
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
127
- post_me = format(post_me, 'xml')
128
- result = make_request(post_me)
129
- return result
130
- end
131
-
132
- def query_list_exturlusage(titles = nil, euprop = nil, euoffset = nil, euprotocol = nil, euquery = nil, eunamespace = nil, eulimit = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
133
-
134
- post_me = add_post('euprop', euprop, post_me)
135
- post_me = add_post('euoffset', euoffset, post_me)
136
- post_me = add_post('euprotocol', euprotocol, post_me)
137
- post_me = add_post('euquery', euquery, post_me)
138
- post_me = add_post('eunamespace', eunamespace, post_me)
139
- post_me = add_post('eulimit', eulimit, post_me)
140
- post_me = add_post('list', 'exturlusage', post_me)
141
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
142
- post_me = format(post_me, 'xml')
143
- result = make_request(post_me)
144
- return result
145
- end
146
-
147
- def query_list_allpages(titles = nil, apfrom = nil, apprefix = nil, apnamespace = nil, apfilterredir = nil, apminsize = nil, apmaxsize = nil, apprtype = nil, apprlevel = nil, apprfiltercascade = nil, aplimit = nil, apdir = nil, apfilterlanglinks = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
148
-
149
- post_me = add_post('apfrom', apfrom, post_me)
150
- post_me = add_post('apprefix', apprefix, post_me)
151
- post_me = add_post('apnamespace', apnamespace, post_me)
152
- post_me = add_post('apfilterredir', apfilterredir, post_me)
153
- post_me = add_post('apminsize', apminsize, post_me)
154
- post_me = add_post('apmaxsize', apmaxsize, post_me)
155
- post_me = add_post('apprtype', apprtype, post_me)
156
- post_me = add_post('apprlevel', apprlevel, post_me)
157
- post_me = add_post('apprfiltercascade', apprfiltercascade, post_me)
158
- post_me = add_post('aplimit', aplimit, post_me)
159
- post_me = add_post('apdir', apdir, post_me)
160
- post_me = add_post('apfilterlanglinks', apfilterlanglinks, post_me)
161
- post_me = add_post('list', 'allpages', post_me)
162
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
163
- post_me = format(post_me, 'xml')
164
- result = make_request(post_me)
165
- return result
166
- end
167
-
168
- def query_meta_allmessages(titles = nil, ammessages = nil, amfilter = nil, amlang = nil, amfrom = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
169
-
170
- post_me = add_post('ammessages', ammessages, post_me)
171
- post_me = add_post('amfilter', amfilter, post_me)
172
- post_me = add_post('amlang', amlang, post_me)
173
- post_me = add_post('amfrom', amfrom, post_me)
174
- post_me = add_post('meta', 'allmessages', post_me)
175
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
176
- post_me = format(post_me, 'xml')
177
- result = make_request(post_me)
178
- return result
179
- end
180
-
181
- def query_list_protectedtitles(titles = nil, ptnamespace = nil, ptlevel = nil, ptlimit = nil, ptdir = nil, ptstart = nil, ptend = nil, ptprop = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
182
-
183
- post_me = add_post('ptnamespace', ptnamespace, post_me)
184
- post_me = add_post('ptlevel', ptlevel, post_me)
185
- post_me = add_post('ptlimit', ptlimit, post_me)
186
- post_me = add_post('ptdir', ptdir, post_me)
187
- post_me = add_post('ptstart', ptstart, post_me)
188
- post_me = add_post('ptend', ptend, post_me)
189
- post_me = add_post('ptprop', ptprop, post_me)
190
- post_me = add_post('list', 'protectedtitles', post_me)
191
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
192
- post_me = format(post_me, 'xml')
193
- result = make_request(post_me)
194
- return result
195
- end
196
-
197
- def query_list_deletedrevs(titles = nil, drstart = nil, drend = nil, drdir = nil, drfrom = nil, drcontinue = nil, drunique = nil, druser = nil, drexcludeuser = nil, drnamespace = nil, drlimit = nil, drprop = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
198
-
199
- post_me = add_post('drstart', drstart, post_me)
200
- post_me = add_post('drend', drend, post_me)
201
- post_me = add_post('drdir', drdir, post_me)
202
- post_me = add_post('drfrom', drfrom, post_me)
203
- post_me = add_post('drcontinue', drcontinue, post_me)
204
- post_me = add_post('drunique', drunique, post_me)
205
- post_me = add_post('druser', druser, post_me)
206
- post_me = add_post('drexcludeuser', drexcludeuser, post_me)
207
- post_me = add_post('drnamespace', drnamespace, post_me)
208
- post_me = add_post('drlimit', drlimit, post_me)
209
- post_me = add_post('drprop', drprop, post_me)
210
- post_me = add_post('list', 'deletedrevs', post_me)
211
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
212
- post_me = format(post_me, 'xml')
213
- result = make_request(post_me)
214
- return result
215
- end
216
-
217
- def query_prop_imageinfo(titles = nil, iiprop = nil, iilimit = nil, iistart = nil, iiend = nil, iiurlwidth = nil, iiurlheight = nil, iicontinue = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
218
-
219
- post_me = add_post('iiprop', iiprop, post_me)
220
- post_me = add_post('iilimit', iilimit, post_me)
221
- post_me = add_post('iistart', iistart, post_me)
222
- post_me = add_post('iiend', iiend, post_me)
223
- post_me = add_post('iiurlwidth', iiurlwidth, post_me)
224
- post_me = add_post('iiurlheight', iiurlheight, post_me)
225
- post_me = add_post('iicontinue', iicontinue, post_me)
226
- post_me = add_post('prop', 'imageinfo', post_me)
227
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
228
- post_me = format(post_me, 'xml')
229
- result = make_request(post_me)
230
- return result
231
- end
232
-
233
- def query_list_blocks(titles = nil, bkstart = nil, bkend = nil, bkdir = nil, bkids = nil, bkusers = nil, bkip = nil, bklimit = nil, bkprop = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
234
-
235
- post_me = add_post('bkstart', bkstart, post_me)
236
- post_me = add_post('bkend', bkend, post_me)
237
- post_me = add_post('bkdir', bkdir, post_me)
238
- post_me = add_post('bkids', bkids, post_me)
239
- post_me = add_post('bkusers', bkusers, post_me)
240
- post_me = add_post('bkip', bkip, post_me)
241
- post_me = add_post('bklimit', bklimit, post_me)
242
- post_me = add_post('bkprop', bkprop, post_me)
243
- post_me = add_post('list', 'blocks', post_me)
244
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
245
- post_me = format(post_me, 'xml')
246
- result = make_request(post_me)
247
- return result
248
- end
249
-
250
- def query_list_alllinks(titles = nil, alcontinue = nil, alfrom = nil, alprefix = nil, alunique = nil, alprop = nil, alnamespace = nil, allimit = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
251
-
252
- post_me = add_post('alcontinue', alcontinue, post_me)
253
- post_me = add_post('alfrom', alfrom, post_me)
254
- post_me = add_post('alprefix', alprefix, post_me)
255
- post_me = add_post('alunique', alunique, post_me)
256
- post_me = add_post('alprop', alprop, post_me)
257
- post_me = add_post('alnamespace', alnamespace, post_me)
258
- post_me = add_post('allimit', allimit, post_me)
259
- post_me = add_post('list', 'alllinks', post_me)
260
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
261
- post_me = format(post_me, 'xml')
262
- result = make_request(post_me)
263
- return result
264
- end
265
-
266
- def query_meta_userinfo(titles = nil, uiprop = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
267
-
268
- post_me = add_post('uiprop', uiprop, post_me)
269
- post_me = add_post('meta', 'userinfo', post_me)
270
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
271
- post_me = format(post_me, 'xml')
272
- result = make_request(post_me)
273
- return result
274
- end
275
-
276
- def query_list_random(titles = nil, rnnamespace = nil, rnlimit = nil, rnredirect = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
277
-
278
- post_me = add_post('rnnamespace', rnnamespace, post_me)
279
- post_me = add_post('rnlimit', rnlimit, post_me)
280
- post_me = add_post('rnredirect', rnredirect, post_me)
281
- post_me = add_post('list', 'random', post_me)
282
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
283
- post_me = format(post_me, 'xml')
284
- result = make_request(post_me)
285
- return result
286
- end
287
-
288
- def query_list_categorymembers(titles = nil, cmtitle = nil, cmprop = nil, cmnamespace = nil, cmcontinue = nil, cmlimit = nil, cmsort = nil, cmdir = nil, cmstart = nil, cmend = nil, cmstartsortkey = nil, cmendsortkey = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
289
-
290
- post_me = add_post('cmtitle', cmtitle, post_me)
291
- post_me = add_post('cmprop', cmprop, post_me)
292
- post_me = add_post('cmnamespace', cmnamespace, post_me)
293
- post_me = add_post('cmcontinue', cmcontinue, post_me)
294
- post_me = add_post('cmlimit', cmlimit, post_me)
295
- post_me = add_post('cmsort', cmsort, post_me)
296
- post_me = add_post('cmdir', cmdir, post_me)
297
- post_me = add_post('cmstart', cmstart, post_me)
298
- post_me = add_post('cmend', cmend, post_me)
299
- post_me = add_post('cmstartsortkey', cmstartsortkey, post_me)
300
- post_me = add_post('cmendsortkey', cmendsortkey, post_me)
301
- post_me = add_post('list', 'categorymembers', post_me)
302
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
303
- post_me = format(post_me, 'xml')
304
- result = make_request(post_me)
305
- return result
306
- end
307
-
308
- def query_list_allusers(titles = nil, aufrom = nil, auprefix = nil, augroup = nil, auprop = nil, aulimit = nil, auwitheditsonly = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
309
-
310
- post_me = add_post('aufrom', aufrom, post_me)
311
- post_me = add_post('auprefix', auprefix, post_me)
312
- post_me = add_post('augroup', augroup, post_me)
313
- post_me = add_post('auprop', auprop, post_me)
314
- post_me = add_post('aulimit', aulimit, post_me)
315
- post_me = add_post('auwitheditsonly', auwitheditsonly, post_me)
316
- post_me = add_post('list', 'allusers', post_me)
317
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
318
- post_me = format(post_me, 'xml')
319
- result = make_request(post_me)
320
- return result
321
- end
322
-
323
- def query_prop_duplicatefiles(titles = nil, dflimit = nil, dfcontinue = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
324
-
325
- post_me = add_post('dflimit', dflimit, post_me)
326
- post_me = add_post('dfcontinue', dfcontinue, post_me)
327
- post_me = add_post('prop', 'duplicatefiles', post_me)
328
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
329
- post_me = format(post_me, 'xml')
330
- result = make_request(post_me)
331
- return result
332
- end
333
-
334
- def query_list_watchlist(titles = nil, wlallrev = nil, wlstart = nil, wlend = nil, wlnamespace = nil, wldir = nil, wllimit = nil, wlprop = nil, wlshow = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
335
-
336
- post_me = add_post('wlallrev', wlallrev, post_me)
337
- post_me = add_post('wlstart', wlstart, post_me)
338
- post_me = add_post('wlend', wlend, post_me)
339
- post_me = add_post('wlnamespace', wlnamespace, post_me)
340
- post_me = add_post('wldir', wldir, post_me)
341
- post_me = add_post('wllimit', wllimit, post_me)
342
- post_me = add_post('wlprop', wlprop, post_me)
343
- post_me = add_post('wlshow', wlshow, post_me)
344
- post_me = add_post('list', 'watchlist', post_me)
345
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
346
- post_me = format(post_me, 'xml')
347
- result = make_request(post_me)
348
- return result
349
- end
350
-
351
- def query_list_search(titles = nil, srsearch = nil, srnamespace = nil, srwhat = nil, srredirects = nil, sroffset = nil, srlimit = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
352
-
353
- post_me = add_post('srsearch', srsearch, post_me)
354
- post_me = add_post('srnamespace', srnamespace, post_me)
355
- post_me = add_post('srwhat', srwhat, post_me)
356
- post_me = add_post('srredirects', srredirects, post_me)
357
- post_me = add_post('sroffset', sroffset, post_me)
358
- post_me = add_post('srlimit', srlimit, post_me)
359
- post_me = add_post('list', 'search', post_me)
360
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
361
- post_me = format(post_me, 'xml')
362
- result = make_request(post_me)
363
- return result
364
- end
365
-
366
- def query_list_embeddedin(titles = nil, eititle = nil, eicontinue = nil, einamespace = nil, eifilterredir = nil, eilimit = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
367
-
368
- post_me = add_post('eititle', eititle, post_me)
369
- post_me = add_post('eicontinue', eicontinue, post_me)
370
- post_me = add_post('einamespace', einamespace, post_me)
371
- post_me = add_post('eifilterredir', eifilterredir, post_me)
372
- post_me = add_post('eilimit', eilimit, post_me)
373
- post_me = add_post('list', 'embeddedin', post_me)
374
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
375
- post_me = format(post_me, 'xml')
376
- result = make_request(post_me)
377
- return result
378
- end
379
-
380
- def query_prop_extlinks(titles = nil, ellimit = nil, eloffset = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
381
-
382
- post_me = add_post('ellimit', ellimit, post_me)
383
- post_me = add_post('eloffset', eloffset, post_me)
384
- post_me = add_post('prop', 'extlinks', post_me)
385
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
386
- post_me = format(post_me, 'xml')
387
- result = make_request(post_me)
388
- return result
389
- end
390
-
391
- def query_list_globalblocks(titles = nil, bgstart = nil, bgend = nil, bgdir = nil, bgids = nil, bgaddresses = nil, bgip = nil, bglimit = nil, bgprop = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
392
-
393
- post_me = add_post('bgstart', bgstart, post_me)
394
- post_me = add_post('bgend', bgend, post_me)
395
- post_me = add_post('bgdir', bgdir, post_me)
396
- post_me = add_post('bgids', bgids, post_me)
397
- post_me = add_post('bgaddresses', bgaddresses, post_me)
398
- post_me = add_post('bgip', bgip, post_me)
399
- post_me = add_post('bglimit', bglimit, post_me)
400
- post_me = add_post('bgprop', bgprop, post_me)
401
- post_me = add_post('list', 'globalblocks', post_me)
402
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
403
- post_me = format(post_me, 'xml')
404
- result = make_request(post_me)
405
- return result
406
- end
407
-
408
- def query_list_watchlistraw(titles = nil, wrcontinue = nil, wrnamespace = nil, wrlimit = nil, wrprop = nil, wrshow = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
409
-
410
- post_me = add_post('wrcontinue', wrcontinue, post_me)
411
- post_me = add_post('wrnamespace', wrnamespace, post_me)
412
- post_me = add_post('wrlimit', wrlimit, post_me)
413
- post_me = add_post('wrprop', wrprop, post_me)
414
- post_me = add_post('wrshow', wrshow, post_me)
415
- post_me = add_post('list', 'watchlistraw', post_me)
416
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
417
- post_me = format(post_me, 'xml')
418
- result = make_request(post_me)
419
- return result
420
- end
421
-
422
- def query_list_usercontribs(titles = nil, uclimit = nil, ucstart = nil, ucend = nil, uccontinue = nil, ucuser = nil, ucuserprefix = nil, ucdir = nil, ucnamespace = nil, ucprop = nil, ucshow = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
423
-
424
- post_me = add_post('uclimit', uclimit, post_me)
425
- post_me = add_post('ucstart', ucstart, post_me)
426
- post_me = add_post('ucend', ucend, post_me)
427
- post_me = add_post('uccontinue', uccontinue, post_me)
428
- post_me = add_post('ucuser', ucuser, post_me)
429
- post_me = add_post('ucuserprefix', ucuserprefix, post_me)
430
- post_me = add_post('ucdir', ucdir, post_me)
431
- post_me = add_post('ucnamespace', ucnamespace, post_me)
432
- post_me = add_post('ucprop', ucprop, post_me)
433
- post_me = add_post('ucshow', ucshow, post_me)
434
- post_me = add_post('list', 'usercontribs', post_me)
435
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
436
- post_me = format(post_me, 'xml')
437
- result = make_request(post_me)
438
- return result
439
- end
440
-
441
- def query_list_logevents(titles = nil, leprop = nil, letype = nil, lestart = nil, leend = nil, ledir = nil, leuser = nil, letitle = nil, lelimit = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
442
-
443
- post_me = add_post('leprop', leprop, post_me)
444
- post_me = add_post('letype', letype, post_me)
445
- post_me = add_post('lestart', lestart, post_me)
446
- post_me = add_post('leend', leend, post_me)
447
- post_me = add_post('ledir', ledir, post_me)
448
- post_me = add_post('leuser', leuser, post_me)
449
- post_me = add_post('letitle', letitle, post_me)
450
- post_me = add_post('lelimit', lelimit, post_me)
451
- post_me = add_post('list', 'logevents', post_me)
452
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
453
- post_me = format(post_me, 'xml')
454
- result = make_request(post_me)
455
- return result
456
- end
457
-
458
- def query_list_backlinks(titles = nil, bltitle = nil, blcontinue = nil, blnamespace = nil, blfilterredir = nil, bllimit = nil, blredirect = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
459
-
460
- post_me = add_post('bltitle', bltitle, post_me)
461
- post_me = add_post('blcontinue', blcontinue, post_me)
462
- post_me = add_post('blnamespace', blnamespace, post_me)
463
- post_me = add_post('blfilterredir', blfilterredir, post_me)
464
- post_me = add_post('bllimit', bllimit, post_me)
465
- post_me = add_post('blredirect', blredirect, post_me)
466
- post_me = add_post('list', 'backlinks', post_me)
467
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
468
- post_me = format(post_me, 'xml')
469
- result = make_request(post_me)
470
- return result
471
- end
472
-
473
- def query_list_allcategories(titles = nil, acfrom = nil, acprefix = nil, acdir = nil, aclimit = nil, acprop = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
474
-
475
- post_me = add_post('acfrom', acfrom, post_me)
476
- post_me = add_post('acprefix', acprefix, post_me)
477
- post_me = add_post('acdir', acdir, post_me)
478
- post_me = add_post('aclimit', aclimit, post_me)
479
- post_me = add_post('acprop', acprop, post_me)
480
- post_me = add_post('list', 'allcategories', post_me)
481
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
482
- post_me = format(post_me, 'xml')
483
- result = make_request(post_me)
484
- return result
485
- end
486
-
487
- def query_list_allimages(titles = nil, aifrom = nil, aiprefix = nil, aiminsize = nil, aimaxsize = nil, ailimit = nil, aidir = nil, aisha1 = nil, aisha1base36 = nil, aiprop = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
488
-
489
- post_me = add_post('aifrom', aifrom, post_me)
490
- post_me = add_post('aiprefix', aiprefix, post_me)
491
- post_me = add_post('aiminsize', aiminsize, post_me)
492
- post_me = add_post('aimaxsize', aimaxsize, post_me)
493
- post_me = add_post('ailimit', ailimit, post_me)
494
- post_me = add_post('aidir', aidir, post_me)
495
- post_me = add_post('aisha1', aisha1, post_me)
496
- post_me = add_post('aisha1base36', aisha1base36, post_me)
497
- post_me = add_post('aiprop', aiprop, post_me)
498
- post_me = add_post('list', 'allimages', post_me)
499
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
500
- post_me = format(post_me, 'xml')
501
- result = make_request(post_me)
502
- return result
503
- end
504
-
505
- def query_prop_info(titles = nil, inprop = nil, intoken = nil, incontinue = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
506
-
507
- post_me = add_post('inprop', inprop, post_me)
508
- post_me = add_post('intoken', intoken, post_me)
509
- post_me = add_post('incontinue', incontinue, post_me)
510
- post_me = add_post('prop', 'info', post_me)
511
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
512
- post_me = format(post_me, 'xml')
513
- result = make_request(post_me)
514
- return result
515
- end
516
-
517
- def query_list_users(titles = nil, usprop = nil, ususers = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
518
-
519
- post_me = add_post('usprop', usprop, post_me)
520
- post_me = add_post('ususers', ususers, post_me)
521
- post_me = add_post('list', 'users', post_me)
522
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
523
- post_me = format(post_me, 'xml')
524
- result = make_request(post_me)
525
- return result
526
- end
527
-
528
- def query_list_recentchanges(titles = nil, rcstart = nil, rcend = nil, rcdir = nil, rcnamespace = nil, rcprop = nil, rctoken = nil, rcshow = nil, rclimit = nil, rctype = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
529
-
530
- post_me = add_post('rcstart', rcstart, post_me)
531
- post_me = add_post('rcend', rcend, post_me)
532
- post_me = add_post('rcdir', rcdir, post_me)
533
- post_me = add_post('rcnamespace', rcnamespace, post_me)
534
- post_me = add_post('rcprop', rcprop, post_me)
535
- post_me = add_post('rctoken', rctoken, post_me)
536
- post_me = add_post('rcshow', rcshow, post_me)
537
- post_me = add_post('rclimit', rclimit, post_me)
538
- post_me = add_post('rctype', rctype, post_me)
539
- post_me = add_post('list', 'recentchanges', post_me)
540
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
541
- post_me = format(post_me, 'xml')
542
- result = make_request(post_me)
543
- return result
544
- end
545
-
546
- def query_list_imageusage(titles = nil, iutitle = nil, iucontinue = nil, iunamespace = nil, iufilterredir = nil, iulimit = nil, iuredirect = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
547
-
548
- post_me = add_post('iutitle', iutitle, post_me)
549
- post_me = add_post('iucontinue', iucontinue, post_me)
550
- post_me = add_post('iunamespace', iunamespace, post_me)
551
- post_me = add_post('iufilterredir', iufilterredir, post_me)
552
- post_me = add_post('iulimit', iulimit, post_me)
553
- post_me = add_post('iuredirect', iuredirect, post_me)
554
- post_me = add_post('list', 'imageusage', post_me)
555
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
556
- post_me = format(post_me, 'xml')
557
- result = make_request(post_me)
558
- return result
559
- end
560
-
561
- def query_prop_templates(titles = nil, tlnamespace = nil, tllimit = nil, tlcontinue = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
562
-
563
- post_me = add_post('tlnamespace', tlnamespace, post_me)
564
- post_me = add_post('tllimit', tllimit, post_me)
565
- post_me = add_post('tlcontinue', tlcontinue, post_me)
566
- post_me = add_post('prop', 'templates', post_me)
567
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
568
- post_me = format(post_me, 'xml')
569
- result = make_request(post_me)
570
- return result
571
- end
572
-
573
- def query_prop_links(titles = nil, plnamespace = nil, pllimit = nil, plcontinue = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
574
-
575
- post_me = add_post('plnamespace', plnamespace, post_me)
576
- post_me = add_post('pllimit', pllimit, post_me)
577
- post_me = add_post('plcontinue', plcontinue, post_me)
578
- post_me = add_post('prop', 'links', post_me)
579
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
580
- post_me = format(post_me, 'xml')
581
- result = make_request(post_me)
582
- return result
583
- end
584
-
585
- def query_prop_categoryinfo(titles = nil, cicontinue = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
586
-
587
- post_me = add_post('cicontinue', cicontinue, post_me)
588
- post_me = add_post('prop', 'categoryinfo', post_me)
589
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
590
- post_me = format(post_me, 'xml')
591
- result = make_request(post_me)
592
- return result
593
- end
594
-
595
- def query_prop_langlinks(titles = nil, lllimit = nil, llcontinue = nil, pageids = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil, post_me = nil)
596
-
597
- post_me = add_post('lllimit', lllimit, post_me)
598
- post_me = add_post('llcontinue', llcontinue, post_me)
599
- post_me = add_post('prop', 'langlinks', post_me)
600
- post_me = query(post_me, titles, pageids, revids, redirects, indexpageids, export, exportnowrap)
601
- post_me = format(post_me, 'xml')
602
- result = make_request(post_me)
603
- return result
604
- end
605
- def delete(title = nil, pageid = nil, token = nil, reason = nil, watch = nil, unwatch = nil, oldimage = nil, post_me = nil)
606
-
607
- post_me = add_post('title', title, post_me)
608
- post_me = add_post('pageid', pageid, post_me)
609
- post_me = add_post('token', token, post_me)
610
- post_me = add_post('reason', reason, post_me)
611
- post_me = add_post('watch', watch, post_me)
612
- post_me = add_post('unwatch', unwatch, post_me)
613
- post_me = add_post('oldimage', oldimage, post_me)
614
- post_me = add_post('action', 'delete', post_me)
615
- post_me = format(post_me, 'xml')
616
- result = make_request(post_me)
617
- return result
618
- end
619
-
620
- def purge(titles = nil, post_me = nil)
621
-
622
- post_me = add_post('titles', titles, post_me)
623
- post_me = add_post('action', 'purge', post_me)
624
- post_me = format(post_me, 'xml')
625
- result = make_request(post_me)
626
- return result
627
- end
628
-
629
- def parse(title = nil, text = nil, page = nil, redirects = nil, oldid = nil, prop = nil, pst = nil, onlypst = nil, post_me = nil)
630
-
631
- post_me = add_post('title', title, post_me)
632
- post_me = add_post('text', text, post_me)
633
- post_me = add_post('page', page, post_me)
634
- post_me = add_post('redirects', redirects, post_me)
635
- post_me = add_post('oldid', oldid, post_me)
636
- post_me = add_post('prop', prop, post_me)
637
- post_me = add_post('pst', pst, post_me)
638
- post_me = add_post('onlypst', onlypst, post_me)
639
- post_me = add_post('action', 'parse', post_me)
640
- post_me = format(post_me, 'xml')
641
- result = make_request(post_me)
642
- return result
643
- end
644
-
645
- def expandtemplates(title = nil, text = nil, generatexml = nil, post_me = nil)
646
-
647
- post_me = add_post('title', title, post_me)
648
- post_me = add_post('text', text, post_me)
649
- post_me = add_post('generatexml', generatexml, post_me)
650
- post_me = add_post('action', 'expandtemplates', post_me)
651
- post_me = format(post_me, 'xml')
652
- result = make_request(post_me)
653
- return result
654
- end
655
-
656
- def edit(title = nil, section = nil, text = nil, token = nil, summary = nil, minor = nil, notminor = nil, bot = nil, basetimestamp = nil, starttimestamp = nil, recreate = nil, createonly = nil, nocreate = nil, captchaword = nil, captchaid = nil, watch = nil, unwatch = nil, md5 = nil, prependtext = nil, appendtext = nil, undo = nil, undoafter = nil, post_me = nil)
657
-
658
- post_me = add_post('title', title, post_me)
659
- post_me = add_post('section', section, post_me)
660
- post_me = add_post('text', text, post_me)
661
- post_me = add_post('token', token, post_me)
662
- post_me = add_post('summary', summary, post_me)
663
- post_me = add_post('minor', minor, post_me)
664
- post_me = add_post('notminor', notminor, post_me)
665
- post_me = add_post('bot', bot, post_me)
666
- post_me = add_post('basetimestamp', basetimestamp, post_me)
667
- post_me = add_post('starttimestamp', starttimestamp, post_me)
668
- post_me = add_post('recreate', recreate, post_me)
669
- post_me = add_post('createonly', createonly, post_me)
670
- post_me = add_post('nocreate', nocreate, post_me)
671
- post_me = add_post('captchaword', captchaword, post_me)
672
- post_me = add_post('captchaid', captchaid, post_me)
673
- post_me = add_post('watch', watch, post_me)
674
- post_me = add_post('unwatch', unwatch, post_me)
675
- post_me = add_post('md5', md5, post_me)
676
- post_me = add_post('prependtext', prependtext, post_me)
677
- post_me = add_post('appendtext', appendtext, post_me)
678
- post_me = add_post('undo', undo, post_me)
679
- post_me = add_post('undoafter', undoafter, post_me)
680
- post_me = add_post('action', 'edit', post_me)
681
- post_me = format(post_me, 'xml')
682
- result = make_request(post_me)
683
- return result
684
- end
685
-
686
- def watch(title = nil, unwatch = nil, post_me = nil)
687
-
688
- post_me = add_post('title', title, post_me)
689
- post_me = add_post('unwatch', unwatch, post_me)
690
- post_me = add_post('action', 'watch', post_me)
691
- post_me = format(post_me, 'xml')
692
- result = make_request(post_me)
693
- return result
694
- end
695
-
696
- def protect(title = nil, token = nil, protections = nil, expiry = nil, reason = nil, cascade = nil, watch = nil, post_me = nil)
697
-
698
- post_me = add_post('title', title, post_me)
699
- post_me = add_post('token', token, post_me)
700
- post_me = add_post('protections', protections, post_me)
701
- post_me = add_post('expiry', expiry, post_me)
702
- post_me = add_post('reason', reason, post_me)
703
- post_me = add_post('cascade', cascade, post_me)
704
- post_me = add_post('watch', watch, post_me)
705
- post_me = add_post('action', 'protect', post_me)
706
- post_me = format(post_me, 'xml')
707
- result = make_request(post_me)
708
- return result
709
- end
710
-
711
- def rollback(title = nil, user = nil, token = nil, summary = nil, markbot = nil, post_me = nil)
712
-
713
- post_me = add_post('title', title, post_me)
714
- post_me = add_post('user', user, post_me)
715
- post_me = add_post('token', token, post_me)
716
- post_me = add_post('summary', summary, post_me)
717
- post_me = add_post('markbot', markbot, post_me)
718
- post_me = add_post('action', 'rollback', post_me)
719
- post_me = format(post_me, 'xml')
720
- result = make_request(post_me)
721
- return result
722
- end
723
-
724
- def feedwatchlist(feedformat = nil, hours = nil, allrev = nil, post_me = nil)
725
-
726
- post_me = add_post('feedformat', feedformat, post_me)
727
- post_me = add_post('hours', hours, post_me)
728
- post_me = add_post('allrev', allrev, post_me)
729
- post_me = add_post('action', 'feedwatchlist', post_me)
730
- post_me = format(post_me, 'xml')
731
- result = make_request(post_me)
732
- return result
733
- end
734
-
735
- def patrol(token = nil, rcid = nil, post_me = nil)
736
-
737
- post_me = add_post('token', token, post_me)
738
- post_me = add_post('rcid', rcid, post_me)
739
- post_me = add_post('action', 'patrol', post_me)
740
- post_me = format(post_me, 'xml')
741
- result = make_request(post_me)
742
- return result
743
- end
744
-
745
- def paraminfo(modules = nil, querymodules = nil, mainmodule = nil, pagesetmodule = nil, post_me = nil)
746
-
747
- post_me = add_post('modules', modules, post_me)
748
- post_me = add_post('querymodules', querymodules, post_me)
749
- post_me = add_post('mainmodule', mainmodule, post_me)
750
- post_me = add_post('pagesetmodule', pagesetmodule, post_me)
751
- post_me = add_post('action', 'paraminfo', post_me)
752
- post_me = format(post_me, 'xml')
753
- result = make_request(post_me)
754
- return result
755
- end
756
-
757
- def move(from = nil, fromid = nil, to = nil, token = nil, reason = nil, movetalk = nil, movesubpages = nil, noredirect = nil, watch = nil, unwatch = nil, post_me = nil)
758
-
759
- post_me = add_post('from', from, post_me)
760
- post_me = add_post('fromid', fromid, post_me)
761
- post_me = add_post('to', to, post_me)
762
- post_me = add_post('token', token, post_me)
763
- post_me = add_post('reason', reason, post_me)
764
- post_me = add_post('movetalk', movetalk, post_me)
765
- post_me = add_post('movesubpages', movesubpages, post_me)
766
- post_me = add_post('noredirect', noredirect, post_me)
767
- post_me = add_post('watch', watch, post_me)
768
- post_me = add_post('unwatch', unwatch, post_me)
769
- post_me = add_post('action', 'move', post_me)
770
- post_me = format(post_me, 'xml')
771
- result = make_request(post_me)
772
- return result
773
- end
774
-
775
- def block(user = nil, token = nil, gettoken = nil, expiry = nil, reason = nil, anononly = nil, nocreate = nil, autoblock = nil, noemail = nil, hidename = nil, allowusertalk = nil, reblock = nil, post_me = nil)
776
-
777
- post_me = add_post('user', user, post_me)
778
- post_me = add_post('token', token, post_me)
779
- post_me = add_post('gettoken', gettoken, post_me)
780
- post_me = add_post('expiry', expiry, post_me)
781
- post_me = add_post('reason', reason, post_me)
782
- post_me = add_post('anononly', anononly, post_me)
783
- post_me = add_post('nocreate', nocreate, post_me)
784
- post_me = add_post('autoblock', autoblock, post_me)
785
- post_me = add_post('noemail', noemail, post_me)
786
- post_me = add_post('hidename', hidename, post_me)
787
- post_me = add_post('allowusertalk', allowusertalk, post_me)
788
- post_me = add_post('reblock', reblock, post_me)
789
- post_me = add_post('action', 'block', post_me)
790
- post_me = format(post_me, 'xml')
791
- result = make_request(post_me)
792
- return result
793
- end
794
-
795
- def emailuser(target = nil, subject = nil, text = nil, token = nil, ccme = nil, post_me = nil)
796
-
797
- post_me = add_post('target', target, post_me)
798
- post_me = add_post('subject', subject, post_me)
799
- post_me = add_post('text', text, post_me)
800
- post_me = add_post('token', token, post_me)
801
- post_me = add_post('ccme', ccme, post_me)
802
- post_me = add_post('action', 'emailuser', post_me)
803
- post_me = format(post_me, 'xml')
804
- result = make_request(post_me)
805
- return result
806
- end
807
-
808
- def undelete(title = nil, token = nil, reason = nil, timestamps = nil, post_me = nil)
809
-
810
- post_me = add_post('title', title, post_me)
811
- post_me = add_post('token', token, post_me)
812
- post_me = add_post('reason', reason, post_me)
813
- post_me = add_post('timestamps', timestamps, post_me)
814
- post_me = add_post('action', 'undelete', post_me)
815
- post_me = format(post_me, 'xml')
816
- result = make_request(post_me)
817
- return result
818
- end
819
-
820
- def import(token = nil, summary = nil, xml = nil, interwikisource = nil, interwikipage = nil, fullhistory = nil, templates = nil, namespace = nil, post_me = nil)
821
-
822
- post_me = add_post('token', token, post_me)
823
- post_me = add_post('summary', summary, post_me)
824
- post_me = add_post('xml', xml, post_me)
825
- post_me = add_post('interwikisource', interwikisource, post_me)
826
- post_me = add_post('interwikipage', interwikipage, post_me)
827
- post_me = add_post('fullhistory', fullhistory, post_me)
828
- post_me = add_post('templates', templates, post_me)
829
- post_me = add_post('namespace', namespace, post_me)
830
- post_me = add_post('action', 'import', post_me)
831
- post_me = format(post_me, 'xml')
832
- result = make_request(post_me)
833
- return result
834
- end
835
-
836
- def unblock(id = nil, user = nil, token = nil, gettoken = nil, reason = nil, post_me = nil)
837
-
838
- post_me = add_post('id', id, post_me)
839
- post_me = add_post('user', user, post_me)
840
- post_me = add_post('token', token, post_me)
841
- post_me = add_post('gettoken', gettoken, post_me)
842
- post_me = add_post('reason', reason, post_me)
843
- post_me = add_post('action', 'unblock', post_me)
844
- post_me = format(post_me, 'xml')
845
- result = make_request(post_me)
846
- return result
847
- end
848
-
849
- # method for adding common parameters for all the methods of the type
850
- # query
851
- def query(post_me = nil, titles = nil, pageid = nil, revids = nil, redirects = nil, indexpageids = nil, export = nil, exportnowrap = nil)
852
- post_me = add_post('titles', titles, post_me)
853
- post_me = add_post('pageid', pageid, post_me)
854
- post_me = add_post('revids', revids, post_me)
855
- post_me = add_post('redirects', redirects, post_me )
856
- post_me = add_post('indexpageids', indexpageids, post_me)
857
- post_me = add_post('export', export, post_me)
858
- post_me = add_post('exportnowrap', exportnowrap, post_me)
859
- post_me = add_post('action', 'query', post_me)
860
- return post_me
861
- end
862
-
863
- #method for defining the format. Currently overriden at make_request
864
- def format(post_me, format = nil)
865
- post_me = add_post('format', format, post_me)
866
- return post_me
867
- end
868
-
869
- #based on rwikibot by Eddie Roger, this method makes a post request to
870
- #the api using the values specified at post_this and the cookies obtained
871
- #during the login (if available)
872
- #
873
- #Returns a xml with the result of the query
874
- def make_request(post_this)
875
- if !post_this.key?('format') or !post_this['format']
876
- post_this['format'] = 'xml'
877
- end
878
-
879
- if @config['logged']
880
- cookies= "#{@config['cookieprefix']}UserName=#{@config['lgusername']}; #{@config['cookieprefix']}UserID=#{@config['lguserid']}; #{@config['cookieprefix']}Token=#{@config['lgtoken']}; #{@config['cookieprefix']}_session=#{@config['_session']}"
881
- else
882
- cookies = ""
883
- end
884
-
885
- headers = {
886
- 'User-agent'=>Ourconfig['user-agent'],
887
- 'Cookie' => cookies
888
- }
889
- uri = URI.parse(@config['api_url'])
890
- request = Net::HTTP::Post.new(uri.path, headers)
891
- request.set_form_data(post_this)
892
- response = Net::HTTP.new(uri.host, uri.port).start { |http|
893
- http.request(request)
894
- }
895
- resputf8 = '<?xml version="1.0" encoding="UTF-8" ?>'+response.body[21..-1]
896
-
897
- return_result = XmlSimple.xml_in(resputf8, { 'ForceArray' => false })
898
- return return_result
899
- end
900
-
901
- def add_post(key, value, post_me = nil)
902
- if !post_me
903
- post_me = Hash.new()
904
- end
905
- if value
906
- post_me[key]=value
907
- end
908
- return post_me
909
- end
910
- end
911
-
912
- #code from rwikibot
913
- class Hash
914
- def to_s
915
- out = "{"
916
- self.each do |key, value|
917
- out += "#{key} => #{value},"
918
- end
919
- out = out.chop
920
- out += "}"
921
- end
922
- end