from linkedin import *
Get an authorization url for your user
l = LinkedinAPI(api_key=*your app key* ,
api_secret=*your app secret* ,
callback_url=http://www.example.com/callback/ ,
permissions=["r_network"])
auth_props = l.get_authentication_tokens()
auth_url = auth_props['auth_url']
oauth_token_secret = auth_props['oauth_token_secret']
print Connect with LinkedIn via: %s % auth_url
If you leave callback_url blank, you can get the oauth_verifier from the web browser. It is a five-digit integer.
The permissions parameter is optional. It can be a list or string. The [list of permissions](https://developer.linkedin.com/documents/authentication) is in the LinkedIn API documentation.
Once you click "Allow" be sure that there is a URL set up to handle getting finalized tokens and possibly adding them to your database to use their information at a later date. \n\n'
oauth_token = Grab oauth token from URL
oauth_verifier = Grab oauth verifier from URL
l = LinkedinAPI(api_key=*your app key* ,
api_secret=*your app secret* ,
oauth_token=oauth_token,
oauth_token_secret=session['linkedin_session_keys']['oauth_token_secret'])
authorized_tokens = l.get_access_token(oauth_verifier)
final_oauth_token = authorized_tokens['oauth_token']
final_oauth_token_secret = authorized_tokens['oauth_token_secret']
l = LinkedinAPI(api_key = *your app key* ,
api_secret = *your app secret* ,
oauth_token=final_tokens['oauth_token'],
oauth_token_secret=final_tokens['oauth_token_secret'])
profile = l.get(people/~ , fields=first-name,last-name )
print profile
search = l.get(people-search , params={'keywords':'Hacker'})
print search
feed = l.get(people/~/network/updates )
print feed
share_content = {
"comment": "Posting from the API using JSON",
"content": {
"title": "A title for your share",
"submitted-url": "http://www.linkedin.com",
"submitted-image-url": "http://lnkd.in/Vjc5ec"
},
"visibility": {
"code": "anyone"
}
}
share_update = l.post(people/~/shares , params=share_content)
print share_update
|