GetProfilesFeed(next.href) not working?

39 views
Skip to first unread message

Apps Guru

unread,
Nov 23, 2009, 3:48:58 AM11/23/09
to Google Contacts API
Hi,
When I try to use Profiles feed functionality in python 2.0.4,

I am able to get 60 results by calling GetProfilesFeed() - 60 is
default number that is returned

After that when I call GetProfilesFeed(next.href) - it does not work,
it keeps giving me first sixty results. I have checked the href value,
it looks fine.

I tried getting the profiles via query parameter - it seems
q.start_index is not supported for profiles, it always starts from 1
irrespective of its value.

Can you please look into this. I need to page through the various
profiles of 250 domain users.

Am I doing something wrong or is this is bug in API code?

Any help is appreciated.

Thanks!!

Julian (Google)

unread,
Nov 24, 2009, 11:49:57 AM11/24/09
to Google Contacts API
Hi,

I was able to reproduce the problem you mention and we are
investigating it.

In the mean time, you could use a bigger number for max-results to get
your whole profiles list, for example using the following URL:
http://www.google.com/m8/feeds/profiles/domain/DOMAIN.COM/full?max-results=300

Cheers,
Julian

Manish Bhargava

unread,
Nov 24, 2009, 12:42:05 PM11/24/09
to google-co...@googlegroups.com
Thanks Julian for the advice.

My problem is that I am calling this from AppEngine for paging through domain users. When max-results are more than 200, the AppEngine times out because of the time taken(I am populating AppEngine db with values from profile feed for individual profile) which times out.

So I cannot rely on max-results. Do you have any idea when this will be fixed. I am happy to take a patch from trunk as and when it becomes available.

Thanks!! 

--

You received this message because you are subscribed to the Google Groups "Google Contacts API" group.
To post to this group, send email to google-co...@googlegroups.com.
To unsubscribe from this group, send email to google-contacts...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-contacts-api?hl=en.



Apps Guru

unread,
Dec 1, 2009, 8:23:09 PM12/1/09
to Google Contacts API
Any updates will be highly appreciated. I am stuck :(

On Nov 24, 10:42 pm, Manish Bhargava <mbhargava...@gmail.com> wrote:
> Thanks Julian for the advice.
>
> My problem is that I am calling this from AppEngine for paging through
> domain users. When max-results are more than 200, the AppEngine times out
> because of the time taken(I am populating AppEngine db with values from
> profile feed for individual profile) which times out.
>
> So I cannot rely on max-results. Do you have any idea when this will be
> fixed. I am happy to take a patch from trunk as and when it becomes
> available.
>
> Thanks!!
>
>
>
> On Tue, Nov 24, 2009 at 8:49 AM, Julian (Google) <j...@google.com> wrote:
> > Hi,
>
> > I was able to reproduce the problem you mention and we are
> > investigating it.
>
> > In the mean time, you could use a bigger number for max-results to get
> > your whole profiles list, for example using the following URL:
>
> >http://www.google.com/m8/feeds/profiles/domain/DOMAIN.COM/full?max-re...
>
> > Cheers,
> > Julian
>
> > On Nov 23, 8:48 am, Apps Guru <mbhargava...@gmail.com> wrote:
> > > Hi,
> > >   When I try to use Profiles feed functionality in python 2.0.4,
>
> > > I am able to get 60 results by calling GetProfilesFeed() - 60 is
> > > default number that is returned
>
> > > After that when I call GetProfilesFeed(next.href) - it does not work,
> > > it keeps giving me first sixty results. I have checked the href value,
> > > it looks fine.
>
> > > I tried getting the profiles via query parameter - it seems
> > > q.start_index is not supported for profiles, it always starts from 1
> > > irrespective of its value.
>
> > > Can you please look into this. I need to page through the various
> > > profiles of 250 domain users.
>
> > > Am I doing something wrong or is this is bug in API code?
>
> > > Any help is appreciated.
>
> > > Thanks!!
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Google Contacts API" group.
> > To post to this group, send email to google-co...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-contacts...@googlegroups.com<google-contacts-api%2Bunsu­bsc...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-contacts-api?hl=en.- Hide quoted text -
>
> - Show quoted text -

Julian (Google)

unread,
Dec 2, 2009, 9:04:46 AM12/2/09
to Google Contacts API
Hi,

The new code for Contacts and Profiles v3 was released with the Python
client library 2.0.5, here is a small example that uses the
pagination:

import sys
import getopt
import getpass
import atom

import gdata.contacts.client
import gdata.contacts.data
import gdata.data

class ContactsSample(object):
"""ContactsSample object demonstrates operations with the Contacts
feed."""

def __init__(self, email, password, domain):
self.gd_client = gdata.contacts.client.ContactsClient();
self.gd_client.client_login(email, password, 'TestApp')
url = self.gd_client.GetFeedUri
(kind='profiles',contact_list=domain)
while url != None:
feed = self.gd_client.GetFeed
(url,desired_class=gdata.contacts.data.ProfilesFeed)
for entry in feed.entry:
self.PrintEntry( entry )
if feed.get_next_link():
url = feed.get_next_link().href
else:
url = None

def PrintEntry(self, entry):
"""Prints out the contents of a single Entry to the console.

Args:
entry: A gdata.contacts.data.ContactEntry
"""
print '\n%s' % (entry.title.text)
# more...

def main():

try:
sample = ContactsSample('AD...@DOMAIN.com', 'PASSWORD',
'DOMAIN.com')
except gdata.client.BadAuthentication:
print 'Invalid user credentials given.'
return


if __name__ == '__main__':
main()
> > >http://groups.google.com/group/google-contacts-api?hl=en.-Hide quoted text -

Manish Bhargava

unread,
Dec 2, 2009, 11:40:27 AM12/2/09
to google-co...@googlegroups.com
Thanks Julian!! This is very helpful.
 
One quick question: I am trying to use this with 2-legged OAuth token in AppEngine instead of using ClientLogin which requires user password.
 
When I was using ContactsService, I was doing:
gContacts.SetOAuthInputParameters(SETTINGS['SIG_METHOD'], SETTINGS['CONSUMER_KEY'],
                              consumer_secret=SETTINGS['CONSUMER_SECRET'],
                                  two_legged_oauth=True, requestor_id=admin_id)
 
I do not see any equivalent 'SetOAuthInputParameter' function in ContactsClient pydocs, using this setter gives error. Am I missing something?
 
Thanks for your help!!

To unsubscribe from this group, send email to google-contacts...@googlegroups.com.

Julian (Google)

unread,
Dec 4, 2009, 12:39:04 PM12/4/09
to Google Contacts API
Hi,

There are many changes with the new v2 classes, I've adapted the
following:
http://gdatatips.blogspot.com/2008/11/2-legged-oauth-in-python.html

and created a small Python 2-legged example (I think we need to get
some help from the Python lib contributors to make a better one):

self.gd_client = gdata.contacts.client.ContactsClient();

CONSUMER_KEY = 'DOMAIN.com'
CONSUMER_SECRET = 'WiR/....'
CONTACTS_URL = 'http://www.google.com/m8/feeds/profiles/domain/
DOMAIN.com/full/'

user = 'AD...@DOMAIN.com'
params = {'max-results': 100, 'xoauth_requestor_id': user}

oauthconsumer = gdata.auth.oauth.OAuthConsumer
(CONSUMER_KEY,CONSUMER_SECRET)
request = gdata.oauth.OAuthRequest.from_consumer_and_token
( oauthconsumer, http_method='GET', http_url=CONTACTS_URL,
parameters=params)
request.sign_request(gdata.oauth.OAuthSignatureMethod_HMAC_SHA1(),
oauthconsumer, None)
headers = request.to_header()
uri = '%s?%s' % (request.http_url, urllib.urlencode(params))
http_request = atom.http_core.HttpRequest(headers=headers)

feed = self.gd_client.GetFeed(uri, http_request=http_request,
desired_class=gdata.contacts.data.ContactsFeed)
for entry in feed.entry:
self.PrintEntry( entry )

def PrintEntry(self, entry):
print '\n%s' % (entry.title.text)

Please if you used this to make a better example, share it back :)

Cheers,
Julian
> > > > > google-contacts...@googlegroups.com<google-contacts-api%2Bunsu bsc...@googlegroups.com><google-contacts-api%2Bunsu
Reply all
Reply to author
Forward
0 new messages