wikidot-api 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +29 -7
- data/lib/wikidot_api/client.rb +5 -4
- data/lib/wikidot_api/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -24,11 +24,10 @@ Before you start using the wikidot-api library, you need an API key. Please cons
|
|
24
24
|
require "wikidot_api"
|
25
25
|
|
26
26
|
api_key = "YOUR_API_KEY_HERE"
|
27
|
-
user_name = "YOUR_USER_NAME_HERE"
|
28
27
|
|
29
|
-
wikidot = WikidotAPI::Client.new
|
28
|
+
wikidot = WikidotAPI::Client.new "wikidot-api", api_key
|
30
29
|
|
31
|
-
|
30
|
+
First argument to the #new method is name of the application using the API. E.g. if you are creating an application called "Best Wikidot API Client", please use its name in the constructor.
|
32
31
|
|
33
32
|
### Calling remote methods
|
34
33
|
|
@@ -37,20 +36,43 @@ The <tt>WikidotAPI::Client</tt> implements <tt>method_missing</tt> method so tha
|
|
37
36
|
is checked agains remote service. This way the library does not need to be updated if RPC methods change, but still provides
|
38
37
|
convenient solution to query the remote service.
|
39
38
|
|
39
|
+
#### Getting list of methods and method descriptions
|
40
|
+
|
41
|
+
Using the RPC methods you can get list of implemented methods and their descriptions.
|
42
|
+
|
43
|
+
puts wikidot.system.listMethods
|
44
|
+
|
45
|
+
at this moment this prints:
|
46
|
+
system.listMethods
|
47
|
+
system.methodHelp
|
48
|
+
system.methodSignature
|
49
|
+
system.multicall
|
50
|
+
site.pages
|
51
|
+
site.categories
|
52
|
+
page.get
|
53
|
+
page.files
|
54
|
+
page.save
|
55
|
+
user.valid
|
56
|
+
user.sites
|
57
|
+
|
58
|
+
To print help about any particular method, try this:
|
59
|
+
|
60
|
+
puts wikidot.system.methodHelp 'page.save'
|
61
|
+
|
40
62
|
#### Example: Listing sites
|
41
63
|
|
42
64
|
The example below uses the remote method <tt>user.sites</tt> that takes one parameter (<tt>user</tt>) and returns a list of sites that this user owns. The method can be called directly on the <tt>wikidot</tt> object.
|
43
65
|
|
44
|
-
sites = wikidot.user.sites
|
66
|
+
sites = wikidot.user.sites "user" => "YOUR_USER_NAME_HERE"
|
45
67
|
sites.each do |site|
|
46
68
|
puts "#{site["title"]}, http://#{site["name"]}.wikidot.com"
|
47
69
|
end
|
48
70
|
|
49
71
|
#### Example: Fetching a page
|
50
72
|
|
51
|
-
page = wikidot.page.get
|
52
|
-
puts page[
|
53
|
-
puts page[
|
73
|
+
page = wikidot.page.get "site" => "YOUR_SITE_NAME_HERE", "page" => "YOUR_PAGE_NAME_HERE"
|
74
|
+
puts page["title"]
|
75
|
+
puts page["source"]
|
54
76
|
|
55
77
|
#### Example: Creating a new page
|
56
78
|
|
data/lib/wikidot_api/client.rb
CHANGED
@@ -5,15 +5,16 @@ module WikidotAPI
|
|
5
5
|
class Client
|
6
6
|
def initialize app, key, opts={}
|
7
7
|
@app, @key = app, key
|
8
|
-
@
|
9
|
-
@proto = opts[:proto] || "https"
|
8
|
+
@host = opts[:host] || "www.wikidot.com"
|
9
|
+
@proto = opts[:proto] || "https"
|
10
|
+
@port = opts[:port] || false
|
10
11
|
end
|
11
12
|
|
12
13
|
def call method, *args
|
13
14
|
try_count = 0
|
14
15
|
begin
|
15
16
|
server.call method, *args
|
16
|
-
rescue
|
17
|
+
rescue IOError => e
|
17
18
|
@server = nil
|
18
19
|
try_count += 1
|
19
20
|
raise if try_count == 3
|
@@ -34,7 +35,7 @@ module WikidotAPI
|
|
34
35
|
end
|
35
36
|
|
36
37
|
def endpoint_uri
|
37
|
-
"#{@proto}://#{@app}:#{@key}@#{@
|
38
|
+
"#{@proto}://#{@app}:#{@key}@#{@host}#{@port ? ':' + @port.to_s : ''}/xml-rpc-api.php"
|
38
39
|
end
|
39
40
|
|
40
41
|
private :server, :endpoint_uri
|
data/lib/wikidot_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wikidot-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Micha\xC5\x82 Fr\xC4\x85ckowiak"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-23 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|