• Technical
  • How to get yahoo messenger status using Java

How to get yahoo messenger status using Java

Hi guys,

Few days back I created an utility for checking the status of user if he/she is online on Yahoo Messenger.

This is a simple utility. Hope you guys have fun using it. 😉 images

Yahoo provides a link for accessing the status of user on Messenger. All you need to write a code that consume a REST web service.

Few days back I published a piece of code to consume REST webservices in Java. We will be using the same code here. In case you want to check this, here is the link for that post: http://blog.niteshapte.com/2013-11-08-how-to-consume-rest-web-service-in-java.htm

Now, back to the point. 😉 The link provided by Yahoo: http://opi.yahoo.com/online?u=yahoo-messenger-id&m=a

And the code:

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

public class YahooMessengerStatusCheck {

        public String checkStatus(String yahooID) {

                String response = null;
                try {

                        URL url = new URL("http://opi.yahoo.com/online?u=" + yahooID +"&m=a"); 
                        HttpURLConnection conn = (HttpURLConnection) url.openConnection();

                        InputStream is = conn.getInputStream();
                        Scanner isScanner = new Scanner(is);

                        StringBuffer buf = new StringBuffer();
                        while(isScanner.hasNextLine()) { 
                        response = buf.toString();

                } catch (IOException e) { 
                return response;

        public static void main(String[] args) {
                new YahooMessengerStatusCheck().checkStatus("yahooID-of-user");

The output that will be displayed on console will be like:
yahooID is ONLINE (in case user is online) or yahooID is NOT ONLINE (if user is offline).

So that’s it guys! Have fun using this utility.

Critics/feedback are very much welcome.

Have  a nice day ahead!

4,052 total views, 1 views today

This entry was posted in Technical

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

Follow Me