Forum: Ruby on Rails Check, and display, AIM status on rails page

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ce01db9bec66e5796cad9fe202acf8e1?d=identicon&s=25 Chris Martin (Guest)
on 2006-02-06 21:58
(Received via mailing list)
Thought I'd post this in case it's of use to anyone. Maybe even a
recipe?

It's just some simple helpers to show AIM status on a webpage.
I searched before coding it, and didn't find anything similar.
Maybe that's because it was so simple :)

These methods belong in a helper (such as
app/helpers/application_helper.rb)

# begin AIM helper methods

def aim_signed_on(screen_name)
  require 'net/http'
  host = "big.oscar.aol.com"
  path = "/#{screen_name}?on_url=online&off_url=offline"
  return true if Net::HTTP.get_response(host, path).header['location']
== "online"
end

def display_aim_status(screen_name)
  if aim_signed_on(screen_name)
    screen_name + " is currently signed on AOL Instant Messenger"
  else
    screen_name + " is currently signed off of AOL Instant Messenger"
  end
end
# end AIM helper

Then just call it from a view with
<%= display_aim_status("YourAIMscreenName") %>

Similar methods could be used for ICQ or Yahoo messenger.

Enjoy.

--
Chris Martin
Web Developer
Open Source & Web Standards Advocate
http://www.chriscodes.com/
F68e4842b0a5487678e26046fdb2fdf3?d=identicon&s=25 softwareengineer 99 (Guest)
on 2006-02-06 22:04
(Received via mailing list)
Hey Chris,

  Thanks for sharing.

  Dave, This would make for a good addition in ROR recipes.

  Frank

Chris Martin <chriscodes@gmail.com> wrote:  Thought I'd post this in
case it's of use to anyone. Maybe even a recipe?

It's just some simple helpers to show AIM status on a webpage.
I searched before coding it, and didn't find anything similar.
Maybe that's because it was so simple :)

These methods belong in a helper (such as
app/helpers/application_helper.rb)

# begin AIM helper methods

def aim_signed_on(screen_name)
  require 'net/http'
  host = "big.oscar.aol.com"
  path = "/#{screen_name}?on_url=online&off_url=offline"
  return true if Net::HTTP.get_response(host, path).header['location']
== "online"
end

def display_aim_status(screen_name)
  if aim_signed_on(screen_name)
    screen_name + " is currently signed on AOL Instant Messenger"
  else
    screen_name + " is currently signed off of AOL Instant Messenger"
  end
end
# end AIM helper

Then just call it from a view with
<%= display_aim_status("YourAIMscreenName") %>

Similar methods could be used for ICQ or Yahoo messenger.

Enjoy.

--
Chris Martin
Web Developer
Open Source & Web Standards Advocate
http://www.chriscodes.com/
This topic is locked and can not be replied to.