简体   繁体   中英

How can I GET the Microsoft Profile Picture through the Graph API in C Sharp

I want to implement Microsoft Profile Pictures with the Graph API in C# to create a UWP App and show these Pics through a HoloLens in Unity.

I found out that you need to use a HTTP Request but I can't get it working in C#.

I'm using the GraphTutorial from Getting Startet with GraphAPI Click here

And I'm starting with a blank page because I don't have any clue how I can get this to work in C#

The GraphExplorer shows me a Picture.

Hope you can help me out!

Greetings

public static async Task<Stream> GetUserPhoto(this GraphServiceClient graph, string userid)
    {
        try
        {
            return await graph
                .Users[userid]
                .Photo
                .Content
                .Request()
                .GetAsync();
        }
        catch
        {
        }





        return null;
    }


    private class Bild
    { 

    private async Task LoadImageAsync(Person person)
    {
      await GetUserPhoto(APPID, EMAIL); 
    }

Check this out: https://github.com/dbarros/WindowsAPICodePack

Maybe try interfacing it with a ShellFile .

ShellFile sf = new ShellFile.FromFilePath(PathToFileHere);
BitMap ShellThumb = sf.Thumbnail.ExtraLargeBitmap;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM