Permalink
Browse files

Adding an example of getting things with the tokens in the db

  • Loading branch information...
1 parent ea8d26a commit a85036412b80907d0e226c6e98e1fac2bbbaafb2 @synedra synedra committed Dec 20, 2011
Showing with 9 additions and 3 deletions.
  1. +9 −3 hellodjango/linkedin/views.py
@@ -49,10 +49,16 @@ def oauth_login(request):
@login_required
def home(request):
now = datetime.datetime.now()
- html = "<html><body>It is now %s.</body></html>" % now
- html += request.user.get_profile().oauth_token
+ html = "<html><body>"
+ token = oauth.Token(request.user.get_profile().oauth_token,request.user.get_profile().oauth_secret)
+ client = oauth.Client(consumer,token)
+ headers = {'x-li-format':'json'}
+ url = "http://api.linkedin.com/v1/people/~:(id,first-name,last-name,headline)"
+ resp, content = client.request(url, "GET", headers=headers)
+ profile = json.loads(content)
+ html += profile['firstName'] + " " + profile['lastName'] + "<br/>" + profile['headline']
return HttpResponse(html)
-
+
@login_required
def oauth_logout(request):
# Log a user out using Django's logout function and redirect them

0 comments on commit a850364

Please sign in to comment.