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.
Usage Examples:
Initialization
Grab picture from API and put it in pictureBox
Grab picture from site and put it in pictureBox
I hope someone somewhere will find this useful. Feel free to critique my code, too.
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.


