c# - Retrieve google contact -
i'm using .net retrieve contact info google contact. however, retrieves including sent email not stored in contact. there anyway can retrieve contact contact?
here code
requestsettings rs = new requestsettings("", email, password); rs.autopaging = true; contactsrequest cr = new contactsrequest(rs); feed<contact> contacts = cr.getcontacts(); foreach (contact contact in contacts.entries) { name name = contact.name; response.write(name.givenname + " " + name.familyname + "<br/>"); foreach (email emailid in contact.emails) { response.write(emailid.address + "<br/>"); } response.write("<br/>"); }
im using google.gdata.contacts package nuget v 2.2.0
string redirecturi = "urn:ietf:wg:oauth:2.0:oob"; // build base oauth2 parameters var oauth2params = new oauth2parameters { clientid = "your google app client id", clientsecret = "your google app client secret", redirecturi = redirecturi }; //security permissions request user string scopes = "https://www.google.com/m8/feeds/ https://apps-apis.google.com/a/feeds/groups/"; oauth2params.scope = scopes; string url = oauthutil.createoauth2authorizationurl(oauth2params); //start default web browser system.diagnostics.process.start(url); //then type access code console console.writeline("please paste access code after authenticating via browser:"); oauth2params.accesscode = console.readline(); oauthutil.getaccesstoken(oauth2params); //store access token securely somewhere //so dont have reauthenticate app @ every start var reqfactory = new goauth2requestfactory(oauth2params.scope, "your google app name", oauth2params); string queryuri = "https://www.google.com/m8/feeds/contacts/default/full"; contactsquery cq = new contactsquery(queryuri); cq.numbertoretrieve = 1000; //cq.group = ...group of desire... contactsservice contactservice = new contactsservice("your google app name"); contactservice.requestfactory = reqfactory; contactsfeed feed = contactservice.query(cq); //then foreach feed.entries
Comments
Post a Comment