Changeset 15075

Show
Ignore:
Timestamp:
07/03/08 07:26:13 (5 years ago)
Author:
hsbt
Message:

use json.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/ruby/misc/wassr_follow_in_twitter.rb

    r15074 r15075  
    22 
    33require 'open-uri' 
    4 require 'rexml/document' 
    5 require 'yaml' 
    6 require 'pathname' 
    74require 'rubygems' 
    85require 'pit' 
     
    2219 
    2320followers = [] 
     21 
    2422begin 
    25         xml = open(TWITTER_API + "statuses/friends.xml", :http_basic_authentication => [twitter_account[:username], twitter_account[:password]]).read 
    26         tw = REXML::Document::new( xml ).root 
     23        tw  = JSON.parse(open(TWITTER_API + "statuses/friends.json", :http_basic_authentication => [twitter_account[:username], twitter_account[:password]]).read) 
    2724 
    28         tw.elements.each("user") do |user| 
    29                 followers << user.elements["screen_name"].text 
     25        tw.each do |user| 
     26                followers << user["screen_name"] 
    3027        end 
    3128 
    32 #       puts "#{followers.join(" ")}" 
     29        puts "#{followers.join(" ")}" 
    3330 
    34         json = open(WASSR_API + "statuses/friends.json", :http_basic_authentication => [wassr_account[:username], wassr_account[:password]]).read 
    35         ws = JSON.parse( json ) 
     31        ws = JSON.parse(open(WASSR_API + "statuses/friends.json", :http_basic_authentication => [wassr_account[:username], wassr_account[:password]]).read) 
    3632 
    3733        ws.each do |user| 
     
    3935        end 
    4036 
    41 #       puts "#{followers.join(" ")}" 
     37        puts "#{followers.join(" ")}" 
    4238         
    4339        followers.each do |name|