[Twitter] Follow กลับ คนที่มา Follow เรา

​Script Follow กลับ ด้าวยภาษา ruby

ก่อนอื่นต้องลง twitter gem ด้วยคำสั่ง sudo gem install twitter (อย่าลืมอัพเดต ก่อนด้วยนะ)

ไฟล์ มีหน้าตาเป็นแบบนี้นะ FILE (.twitter)

email: my_twitter_email password: my_twitter_password

#!/usr/bin/env ruby
require 'rubygems'
require 'twitter'

config = YAML::load(open(".twitter")) httpauth = Twitter::HTTPAuth.new(config['email'], config['password']) = Twitter::.new(httpauth)

base.followers.each do |follower| if !follower.following begin base.friendship_create(follower.id, true) rescue puts "An error occurred: #{$!}" end puts "Created friendship with #{follower.screen_name}" end end ได้มาจาก http://travisonrails.com/2009/04/22/Twitter-Gem-Examples

Related Blogs

เรื่องที่เกี่ยวข้อง

ใส่ความเห็น

อีเมล์ของคุณจะไม่แสดงให้คนอื่นเห็น ช่องที่ต้องการถูกทำเครื่องหมาย *

*

คุณอาจจะใช้ป้ายกำกับและคุณสมบัติHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>