Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

Skype Avatar Grabber

A lot of Skype tools use the website to get user profiles off of. This is a problem, because a lot of people have privacy settings on their profiles. For this reason, I made a class that has two options for avatar grabbing: The site, or the API. The difference between using the site and the API, is that if the user is on your contacts, the SKYPE4COMLIB API will 100% download their profile picture. How I'd recommend using this class, is doing a check if the user that's handle is trying to be grabbed is on your contacts list, then call either method accordingly.

Code
using SKYPE4COMLib;
using System.Drawing;
using System.IO;
using System.Threading;

namespace skypeTest
{
    class avatarGrabber
    {
        private Skype s;

        public avatarGrabber(Skype S)
        {
            s = S;
        }

        public Bitmap grabAvatarAPI(string handle) //Saves users image from Skype using the API, then returns it as bitmap
        {
            Command c = new Command();
            File.Delete(Path.GetTempPath() + handle + ".png");
            c.Command = string.Format("GET USER {0} AVATAR 1 {1}", handle, Path.GetTempPath() + handle + ".png");
            s.SendCommand(c);
            Thread.Sleep(100); //THIS IS MANDATORY
            return new Bitmap(Path.GetTempPath() + handle + ".png");
        }

        public string grabAvatarOnline(string handle) //Downloads it off Skypes website. You get the profile picture as if you aren't a contact. returns string
        {
            return "http://api.skype.com/users/" + handle + "/profile/avatar";
        }
    }
}


Usage Examples:

Initialization

Code
avatarGrabber a = new avatarGrabber(nameOfSkype)

Grab picture from API and put it in pictureBox

Code
pictureBox1.Image = a.grabAvatarAPI("insertaccountnamehere");

Grab picture from site and put it in pictureBox

Code
pictureBox1.ImageLocation = a.grabAvatarOnline("insertaccountnamehere");

I hope someone somewhere will find this useful. Feel free to critique my code, too.
You should add the site as fallback method. So the class tries to first get the profile picture via the SKYPE4COM lib and if that doesn't work then it uses the site.
Hello! is working for you a message send?


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Shell] by shotzinthedarkJan 20, 2017 01:50 PM 12 1,013 Jan 20, 2017 01:50 PM
Last Post: DataBuster
[.NET] by deiskiApr 14, 2016 10:51 AM 4 296 Apr 14, 2016 10:51 AM
Last Post: Ninja
[C#] by #EnigmaMay 25, 2013 03:03 PM 1 911 May 25, 2013 03:03 PM
Last Post: x64