Created
August 1, 2011 08:49
-
-
Save dongyuwei/1117813 to your computer and use it in GitHub Desktop.
打印出新浪微博xmpp好友分组及各组内好友
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'xmpp4r' | |
require 'xmpp4r/roster/helper/roster' | |
#Jabber::debug = true | |
jid = Jabber::JID.new('[email protected]')#my weibo uid | |
cl = Jabber::Client.new(jid) | |
cl.connect | |
cl.auth('xxxxx')#my weibo password | |
# The roster instance | |
roster = Jabber::Roster::Helper.new(cl) | |
mainthread = Thread.current | |
roster.add_query_callback { |iq| | |
mainthread.wakeup | |
} | |
Thread.stop | |
#打印出微博xmpp好友分组及各组内好友 | |
roster.groups.each { |group| | |
if group.nil? | |
puts "*** Ungrouped ***" | |
else | |
puts "*** #{group} ***" | |
end | |
roster.find_by_group(group).each { |item| | |
puts "- #{item.iname} (#{item.jid})" | |
} | |
print "\n" | |
} | |
cl.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment