2013-04-10 22 views
0

我正在尝试使用gdata以获取我的用户在我的网站上的联系人。在Django中设置gdata以检索Google联系人

到目前为止我已经做了一个pip安装gdata。

然后我说我的views.py的顶部

CLIENT_ID = 'mythingy' # Provided in the APIs console 
CLIENT_SECRET = 'mythingy' # Provided in the APIs console 
SCOPE = 'https://www.google.com/m8/feeds' 
USER_AGENT = 'dummy-sample' 

我有我的网页上一个按钮,没有按什么,但我想,如果你点击它,它应该问你persmission然后打开一个弹出与用户的Gmail联系。

我想知道如何实现htat。

在我的意见,到目前为止,我有:

@login_required 
def activate_user(request, activation_key): 

    user = User.objects.get(username=request.user) 
    profile = user.get_profile() 
    auth_token = gdata.gauth.OAuth2Token(client_id=CLIENT_ID,client_secret=CLIENT_SECRET,scope=SCOPE,user_agent=USER_AGENT) 

    APPLICATION_REDIRECT_URI = 'http://127.0.0.1:8000/oauth2callback' 
    authorize_url=auth_token.generate_authorize_url(redirect_uri=APPLICATION_REDIRECT_URI) 

    return render_to_response('registration/activation_complete.html',{'user': user,'profile':profile}, context_instance=RequestContext(request)) 

但这没什么。 我没有碰我的urls.py或我的settings.py 谢谢

回答

0

我最终使用JavaScript API。如果任何人需要的代码让我知道

+0

你是怎么做到的,通过使用javascript api – 2015-02-10 09:10:33

+0

是的JS。如果你需要 – 2015-02-24 01:53:53

+0

,那么我应该还是有代码的地方,你可以在这里发布代码,这将是一个很好的帮助 – 2015-02-24 05:05:09