Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
c2651497
Commit
c2651497
authored
Dec 20, 2013
by
Chris Rossi
Committed by
Diana Huang
Jan 16, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pylint
parent
f2862965
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletions
+13
-1
lms/djangoapps/linkedin/management/commands/__init__.py
+12
-0
lms/djangoapps/linkedin/management/commands/linkedin_mailusers.py
+1
-1
No files found.
lms/djangoapps/linkedin/management/commands/__init__.py
View file @
c2651497
...
...
@@ -60,6 +60,9 @@ class LinkedinAPI(object):
return
query
[
'code'
][
0
]
def
access_token_url
(
self
,
code
):
"""
Construct URL for retreiving access token, given authorization code.
"""
config
=
self
.
config
return
(
"https://www.linkedin.com/uas/oauth2/accessToken"
"?grant_type=authorization_code"
...
...
@@ -68,6 +71,9 @@ class LinkedinAPI(object):
config
[
'CLIENT_SECRET'
]))
def
call_json_api
(
self
,
url
):
"""
Make an HTTP call to the LinkedIn JSON API.
"""
try
:
request
=
urllib2
.
Request
(
url
,
headers
=
{
'x-li-format'
:
'json'
})
response
=
urllib2
.
urlopen
(
request
)
.
read
()
...
...
@@ -92,12 +98,18 @@ class LinkedinAPI(object):
return
access_token
def
require_token
(
self
):
"""
Raise CommandError if user has not yet obtained an access token.
"""
if
self
.
token
is
None
:
raise
CommandError
(
"You must log in to LinkedIn in order to use this script. "
"Please use the 'login' command to log in to LinkedIn."
)
def
batch_url
(
self
,
emails
):
"""
Construct URL for querying a batch of email addresses.
"""
self
.
require_token
()
queries
=
','
.
join
((
"email="
+
email
for
email
in
emails
))
url
=
"https://api.linkedin.com/v1/people::(
%
s):(id)"
%
queries
...
...
lms/djangoapps/linkedin/management/commands/linkedin_mailusers.py
View file @
c2651497
...
...
@@ -42,7 +42,7 @@ class Command(BaseCommand):
"certificate mail form will be used."
),)
def
__init__
(
self
):
super
(
Base
Command
,
self
)
.
__init__
()
super
(
Command
,
self
)
.
__init__
()
self
.
api
=
LinkedinAPI
(
self
)
def
handle
(
self
,
*
args
,
**
options
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment