开发者

How to get the contact photo of a Google account using Google Contacts Data API by C#

开发者 https://www.devze.com 2023-02-25 01:59 出处:网络
I\'m writting a small program to show all contact photos of a Google account. I 开发者_运维问答wrote it :

I'm writting a small program to show all contact photos of a Google account. I 开发者_运维问答wrote it :

RequestSettings rs = new RequestSettings("", inputEmail.Text, inputPassword.Text);
ContactsRequest cr = new ContactsRequest(rs);
Feed<Contact> fd = cr.GetContacts();
foreach (Contact contact in fd.Entries)
{
    try
    {
        contact.ContactEntry.
        photo= Image.FromStream(cr.GetPhoto(contact));
        Console.WriteLine("OK");
        // ...Other work

    }
    catch (Exception ex)
    {
                   MessageBox.Show(ex.Message);
    }
}

But it didn't work. I alway get the "Google.GData.Client.GDataNotModifiedException" error. Who can help me fix it. Thanks so much !


To save anyone having to follow the link:

Stream s = cr.Service.Query(contact.PhotoUri);
Image img = Image.FromStream(s);
0

精彩评论

暂无评论...
验证码 换一张
取 消