के साथ संपर्क के बारे में जानकारी प्राप्त करना मैं हाल ही में जारी किए गए Google की पीपुल्स एपीआई का उदाहरण here से उपयोग कर रहा हूं। मैंने एक ईमेल पता और एक फोन नंबर जैसे संपर्क के बारे में अतिरिक्त जानकारी प्रदर्शित करने के लिए एक नमूना बढ़ाया है। कोड जो काम करना चाहिए नीचे प्रस्तुत किया गया है।Google पीपुल्स एपीआई (जावा)
public class PeopleQuickstart {
...
public static void getPersonInfo(Person person){
// Get names
List<Name> names = person.getNames();
if(names != null && names.size() > 0) {
for(Name personName: names) {
System.out.println("Name: " + personName.getDisplayName());
}
}
// Get email addresses
List<EmailAddress> emails = person.getEmailAddresses();
if(emails != null && emails.size() > 0) {
for(EmailAddress personEmail: emails) {
System.out.println("Email: " + personEmail.getValue());
}
}
// Get phone numbers
List<PhoneNumber> phones = person.getPhoneNumbers();
if(phones != null && phones.size() > 0) {
for(PhoneNumber personPhone: phones){
System.out.println("Phone number: " + personPhone.getValue());
}
}
}
public static void main(String [] args) throws IOException {
People service = getPeopleService();
// Request 120 connections.
ListConnectionsResponse response = service.people().connections()
.list("people/me")
.setPageSize(120)
.execute();
// Display information about your connections.
List<Person> connections = response.getConnections();
if (connections != null && connections.size() > 0) {
for (Person person: connections){
getPersonInfo(person);
}
} else {
System.out.println("No connections found.");
}
}
}
मैं अपने संपर्क सूची के साथ इस कार्यक्रम का परीक्षण कर रहा हूँ और मैं सफलतापूर्वक नाम फ़ील्ड के साथ-साथ लोगों की एक सूची प्राप्त कर सकते हैं। हालांकि, मुझे ईमेल पते और फोन नंबरों के लिए मूल्य नहीं मिल सकते हैं (सूचियां हमेशा शून्य होती हैं), हालांकि मेरे पास इन मानों को मेरी संपर्क सूची में सेट किया गया है (जीमेल-> संपर्कों के माध्यम से सत्यापित)। मैं क्या खो रहा हूँ?
भावी पीढ़ी के लिए, यहाँ वैध अनुरोध मास्क की सूची है person.genders, person.im_clients, person.interests, person.locales, person.memberships, person.metadata, person.names, person.nicknames, person.occupations, person.organizations, person.phone_numbers, person.photos, व्यक्ति। रिलेशनशिप, person.relationship_interests, person.relationship_statuses, person.residences, person.skills, person.taglines, person.urls – GBleaney
वही समस्या थी (http://stackoverflow.com/questions/36466050/why-cant-i-retrieve -emails-पतों और फोन-नंबर-साथ-google-लोगों-api)। खुशी है कि आपको समाधान मिला। हमें इसे Google को रिपोर्ट करनी चाहिए। – nunoarruda
@ फ़ामा धन्यवाद, यह मुझे बचाता है। – Ankur1994a