rfetion 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +10 -4
- data/VERSION +1 -1
- data/lib/rfetion/fetion.rb +32 -6
- data/rfetion.gemspec +1 -1
- metadata +1 -1
data/README.textile
CHANGED
@@ -21,22 +21,28 @@ gem install rfetion
|
|
21
21
|
|
22
22
|
h2. Usage
|
23
23
|
|
24
|
-
send sms to friends or yourself
|
24
|
+
* send sms to friends or yourself
|
25
|
+
|
25
26
|
<pre><code>
|
26
27
|
Fetion.send_sms(mobile_no, password, mobile_or_fetion_numbers, content)
|
27
28
|
</code></pre>
|
28
29
|
|
29
|
-
|
30
|
+
if mobile_or_fetion_numbers are nil, send sms to yourself.
|
31
|
+
|
32
|
+
* add friend with mobile
|
33
|
+
|
30
34
|
<pre><code>
|
31
35
|
Fetion.add_buddy_with_mobile(mobile_no, password, friend_mobile)
|
32
36
|
</code></pre>
|
33
37
|
|
34
|
-
add friend with sip
|
38
|
+
* add friend with sip
|
39
|
+
|
35
40
|
<pre><code>
|
36
41
|
Fetion.add_buddy_with_sip(mobile_no, password, friend_sip)
|
37
42
|
</code></pre>
|
38
43
|
|
39
|
-
send schedule sms to friends
|
44
|
+
* send schedule sms to friends
|
45
|
+
|
40
46
|
<pre><code>
|
41
47
|
Fetion.schedule_sms(mobile_no, password, mobile_or_fetion_number, content, time)
|
42
48
|
</code></pre>
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.1
|
data/lib/rfetion/fetion.rb
CHANGED
@@ -86,6 +86,7 @@ class Fetion
|
|
86
86
|
fetion.password = password
|
87
87
|
fetion.login
|
88
88
|
fetion.register
|
89
|
+
fetion.get_personal_info
|
89
90
|
fetion.add_buddy_with_mobile(friend_mobile)
|
90
91
|
fetion.logout
|
91
92
|
end
|
@@ -97,6 +98,7 @@ class Fetion
|
|
97
98
|
fetion.password = password
|
98
99
|
fetion.login
|
99
100
|
fetion.register
|
101
|
+
fetion.get_personal_info
|
100
102
|
fetion.add_buddy_with_sip(friend_sip)
|
101
103
|
fetion.logout
|
102
104
|
end
|
@@ -141,7 +143,7 @@ class Fetion
|
|
141
143
|
def register
|
142
144
|
@logger.info "fetion http register"
|
143
145
|
call = next_call
|
144
|
-
arg = '<args><device type="PC" version="
|
146
|
+
arg = '<args><device type="PC" version="284571220" client-version="3.3.0370" /><caps value="simple-im;im-session;temp-group;personal-group" /><events value="contact;permission;system-message;personal-group" /><user-info attributes="all" /><presence><basic value="400" desc="" /></presence></args>'
|
145
147
|
|
146
148
|
register_first(call, arg)
|
147
149
|
|
@@ -260,20 +262,44 @@ class Fetion
|
|
260
262
|
@logger.info "fetion schedule send sms to #{receivers.join(', ')} success"
|
261
263
|
end
|
262
264
|
|
263
|
-
def
|
265
|
+
def get_personal_info
|
266
|
+
@logger.info "fetion get personal info"
|
267
|
+
arg = %Q{<args><personal attributes="all" /><services version="" attributes="all" /><config version="96" attributes="all" /><mobile-device attributes="all" /></args>}
|
268
|
+
msg = sip_create('S fetion.com.cn SIP-C/2.0', {'F' => @sid, 'I' => next_call, 'Q' => '1 S', 'N' => 'GetPersonalInfo'}, arg) + FETION_SIPP
|
269
|
+
curl_exec(next_url, @ssic, msg)
|
270
|
+
response = curl_exec(next_url, @ssic, FETION_SIPP)
|
271
|
+
raise FetionException.new("Fetion Error: Get personal info error") unless response.is_a? Net::HTTPSuccess
|
272
|
+
|
273
|
+
doc = REXML::Document.new(response.body.chomp(FETION_SIPP))
|
274
|
+
doc.elements.each('results/personal') do |person|
|
275
|
+
@person = person.attributes
|
276
|
+
end
|
277
|
+
@logger.info "fetion get personal info success"
|
278
|
+
end
|
279
|
+
|
280
|
+
def add_buddy_with_mobile(mobile)
|
264
281
|
@logger.info "fetion send request to add mobile:#{mobile} as friend"
|
265
|
-
arg = %Q{<args><contacts><buddies><buddy uri="tel:#{mobile}" local-name="
|
282
|
+
arg = %Q{<args><contacts><buddies><buddy uri="tel:#{mobile}" local-name="" buddy-lists="1" desc="#{@person['nickname']}" expose-mobile-no="1" expose-name="1" /></buddies></contacts></args>}
|
266
283
|
msg = sip_create('S fetion.com.cn SIP-C/2.0', {'F' => @sid, 'I' => next_call, 'Q' => '1 S', 'N' => 'AddBuddy'}, arg) + FETION_SIPP
|
267
284
|
curl_exec(next_url, @ssic, msg)
|
268
285
|
response = curl_exec(next_url, @ssic, FETION_SIPP)
|
269
|
-
|
270
286
|
raise FetionException.new("Fetion Error: Add buddy error") unless response.is_a? Net::HTTPSuccess
|
287
|
+
|
288
|
+
if response.body =~ /No Subscription/
|
289
|
+
arg = %Q{<args><contacts><mobile-buddies><mobile-buddy uri="tel:#{mobile}" local-name="" buddy-lists="1" desc="#{@person['nickname']}" expose-mobile-no="1" expose-name="1" /></mobile-buddies></contacts></args>}
|
290
|
+
msg = sip_create('S fetion.com.cn SIP-C/2.0', {'F' => @sid, 'I' => next_call, 'Q' => '1 S', 'N' => 'AddMobileBuddy'}, arg) + FETION_SIPP
|
291
|
+
curl_exec(next_url, @ssic, msg)
|
292
|
+
response = curl_exec(next_url, @ssic, FETION_SIPP)
|
293
|
+
raise FetionException.new("Fetion Error: Add buddy error") unless response.is_a? Net::HTTPSuccess
|
294
|
+
|
295
|
+
raise FetionException.new("Fetion Error: No this mobile") if response.body =~ /Not Found/
|
296
|
+
end
|
271
297
|
@logger.info "fetion send request to add mobile:#{mobile} as friend success"
|
272
298
|
end
|
273
299
|
|
274
|
-
def add_buddy_with_sip(sip
|
300
|
+
def add_buddy_with_sip(sip)
|
275
301
|
@logger.info "fetion send request to add sip:#{sip} as friend"
|
276
|
-
arg = %Q{<args><contacts><buddies><buddy uri="sip:#{sip}" local-name="
|
302
|
+
arg = %Q{<args><contacts><buddies><buddy uri="sip:#{sip}" local-name="" buddy-lists="1" desc="#{@person['nickname']}" expose-mobile-no="1" expose-name="1" /></buddies></contacts></args>}
|
277
303
|
msg = sip_create('S fetion.com.cn SIP-C/2.0', {'F' => @sid, 'I' => next_call, 'Q' => '1 S', 'N' => 'AddBuddy'}, arg) + FETION_SIPP
|
278
304
|
curl_exec(next_url, @ssic, msg)
|
279
305
|
response = curl_exec(next_url, @ssic, FETION_SIPP)
|
data/rfetion.gemspec
CHANGED