我想导入gmail的联系人。我已成功导入朋友的姓名,电话和电子邮件地址,但我也要导入朋友的照片和DOB。
我做了很多R& D但没有找到和解决方案。请帮忙......
答案 0 :(得分:0)
检查 Google Contacts API
https://developers.google.com/google-apps/contacts/v3/#retrieving_a_contacts_photo
要检索联系人的照片,请将授权的GET请求发送给 联系人的照片链接网址。
网址格式为:
https://www.google.com/m8/feeds/photos/media/ {USEREMAIL} / {的ContactID}
使用适当的值代替userEmail和contactID。
public static void DownloadPhoto(ContactsRequest cr, Uri contactURL)
{
Contact contact = cr.Retrieve<Contact>(contactURL);
Stream photoStream = cr.GetPhoto(contact);
FileStream outStream = File.OpenWrite("test.jpg");
byte[] buffer = new byte[photoStream.length];
photoStream.Read(buffer, 0, photoStream.length);
outStream.Write(buffer, 0, photoStream.length);
photoStream.Close();
outStream.Close();
}