2011-03-07 3 views
0

Я пытаюсь получить доступ к имени группы всех записей в моем списке контактов. Как я могу получить доступ к деталям группы с учетом ссылки href?Получение имени группы с помощью gdata api

Это выходной ток:

9 Albert Gandhi 2011-03-07T09:48:19.824Z 
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me. 
    [email protected] 
    Member of group: http://www.google.com/m8/feeds/groups/blah.blah%40blah.com/base/4c8d4c8d8d218d21 

Но я хотел бы что-то вроде этого:

9 Albert Gandhi 2011-03-07T09:48:19.824Z 
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me. 
    [email protected] 
    Member of group: GroupName 

Ниже приведен код, я использую, чтобы перечислить фид контакт (взятый в основном из примеров с использованием API)

def PrintFeed(self, feed, ctr=0): 
    """Prints out the contents of a feed to the console. 

    Args: 
     feed: A gdata.contacts.ContactsFeed instance. 
     ctr: [int] The number of entries in this feed previously printed. This 
      allows continuous entry numbers when paging through a feed. 

    Returns: 
     The number of entries printed, including those previously printed as 
     specified in ctr. This is for passing as an argument to ctr on 
     successive calls to this method. 

    """ 
    if not feed.entry: 
     print '\nNo entries in feed.\n' 
     return 0 
    for i, entry in enumerate(feed.entry): 
     print '\n%s %s %s' % (ctr+i+1, entry.title.text, entry.updated.text) 
     if entry.content: 
     print ' %s' % (entry.content.text) 
     for email in entry.email: 
     if email.primary and email.primary == 'true': 
      print ' %s' % (email.address) 
     # Show the contact groups that this contact is a member of. 
     for group in entry.group_membership_info: 
     print ' Member of group: %s' % (group.href) 
     # Display extended properties. 
     for extended_property in entry.extended_property: 
     if extended_property.value: 
      value = extended_property.value 
     else: 
      value = extended_property.GetXmlBlobString() 
     print ' Extended Property %s: %s' % (extended_property.name, value) 
    return len(feed.entry) + ctr 
+0

@gonvaled Откуда приходит ** «GroupName» **, мы видим, что вы показываете в качестве строки, которую хотите в качестве результата для «Член группы:»? http://www.google.com/m8/feeds/groups/blah.blah%40blah.com/base/4c8d4c8d8d218d21 - ** group.href **, насколько я не хочу. Поэтому вы должны найти атрибут группы, который даст имя GroupName. Что еще ?? – eyquem

+0

GroupName - это просто заполнитель. Там должно быть имя реальной группы, например «Друзья», «Коллеги» или любое настраиваемое имя группы. Проблема в том, что я не знаю, как получить доступ к этой информации, начиная с href группы. – dangonfast

+0

@gonvaled Мы не можем знать больше. Я пробовал адрес, результат - _Authorization required Ошибка 401_ Кажется, это частная база данных или сайт. Как вы хотите, чтобы люди могли получать информацию из частного места? – eyquem

ответ

0

Для справки вы можете найти решение по этому вопросу here

Смежные вопросы