Pages Menu
TwitterRssFacebook

Posted by on May 12, 2015 in Learn Skype Web SDK

Learn Skype Web SDK Day 9 : Getting & Displaying Contact Photos

Learn Skype Web SDK Day 9 : Getting & Displaying Contact Photos

[contemplate-1]
View Demo

In Skype for Business, people have photos associated with them, so that they can easily be identified. Often these are administered in Active Directory alongside other information such as job title, department etc.

In Skype for Web API these photos can be accessed. They are a property of the person object, which means they can get accessed with a get() comamnd. The property name is avatarURL. To get the value you would first get a handle to the person object (which can be yourself, or another contact) and then call get() on the property:

[code language=”javascript”]

person.avatarUrl.get().then(function(value) {
//do something with the photo
});

[/code]

The return object isn’t the actual photo – it’s a URL describing the photo. For instance, you might get back this URL:

https://lyncweb.thoughtstuff.co.uk/ucwa/oauth/v1/applications/114079659624/photos/[email protected]

This URL has been crafted together for us by Skype for Web API (well, actually UCWA but it doesn’t matter) and if you were to load that in a browser, you’d see the image.

This means that you can provide the URL as the source attribute to a HTTP image container you have created, or do something else with it in JavaScript etc. To set it as the source for an image you might do this:

[code language=”javascript”]

$(‘#imgContactPhoto’).attr(“src”,value);

[/code]

Here’s a full code sample which demonstrates these functions:

[code language=”javascript”]


Your Photo:

[/code]

Demo Online

You can try this code out against your own Skype for Business environment by going to the demo page. From here you can also download the code from GitHub if you want to host it locally, or take it and use it in your next project.
[contemplate-2]

Post a Reply

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