Linkedin_api_example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#! /usr/bin/env python
# -*- coding: utf-8 -*-

CONSUMER_KEY = 'xxxxxxx'     # This is api_key
CONSUMER_SECRET = 'xxxxxxx'   # This is secret_key

USER_TOKEN = 'xxxxxxx'   # This is oauth_token
USER_SECRET = 'xxxxxxx'   # This is oauth_secret
RETURN_URL = 'http://localhost:8000'

from linkedin import linkedin
from oauthlib import *
from urllib2 import *
import urllib2
from json import dumps, loads
# Define CONSUMER_KEY, CONSUMER_SECRET,  
# USER_TOKEN, and USER_SECRET from the credentials 
# provided in your LinkedIn application

# Instantiate the developer authentication class
authentication = linkedin.LinkedInDeveloperAuthentication(CONSUMER_KEY, CONSUMER_SECRET, 
                                                      USER_TOKEN, USER_SECRET, 
                                                      RETURN_URL, linkedin.PERMISSIONS.enums.values())

# Pass it in to the app...
application = linkedin.LinkedInApplication(authentication)

print application.get_profile()

print application.get_profile(selectors=['id', 'first-name', 'last-name', 'location', 'distance', 'num-connections', 'skills', 'educations'])

print application.search_company(selectors=[{'companies': ['name', 'universal-name', 'website-url']}], params={'keywords': 'apple microsoft'})
# Search URL is https://api.linkedin.com/v1/company-search:(companies:(name,universal-name,webs

print application.get_memberships(params={'count': 20})

print application.get_companies(company_ids=[1035], universal_names=['apple'], selectors=['name'], params={'is-company-admin': 'true'})
Comments

Comments