Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some extra features. #89

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 45 additions & 6 deletions linkedin/linkedin.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,16 @@ def leave_group(self, group_id):
raise_for_error(response)
return True

def submit_group_post(self, group_id, title, summary, submitted_url,
submitted_image_url, content_title, description):
post = {
'title': title, 'summary': summary,
'content': {
def submit_group_post(self, group_id, title, summary, submitted_url=None,
submitted_image_url=None, content_title=None,
description=None):
post = {'title': title, 'summary': summary}
if content_title and submitted_url:
post['content'] = {
'submitted-url': submitted_url,
'title': content_title,
'description': description
}
}
if submitted_image_url:
post['content']['submitted-image-url'] = submitted_image_url

Expand Down Expand Up @@ -541,3 +541,42 @@ def like_update(self, update_key, is_liked=True):
response = self.make_request('PUT', url, data=json.dumps(is_liked))
raise_for_error(response)
return True

def get_post_likes(self, post_id, selectors=None, params=None,
headers=None):
url = '%s/%s/likes' % (ENDPOINTS.POSTS, post_id)
if selectors:
url = '%s:(%s)' % (url, LinkedInSelector.parse(selectors))

response = self.make_request('GET', url, params=params, headers=headers)
raise_for_error(response)
return response.json()

def get_share_comments(self, post_id, selectors=None, params=None,
headers=None):
url = '%s/~/network/updates/key=%s/update-comments' % (ENDPOINTS.PEOPLE,
post_id)
if selectors:
url = '%s:(%s)' % (url, LinkedInSelector.parse(selectors))

response = self.make_request('GET', url, params=params, headers=headers)
raise_for_error(response)
return response.json()

def get_share_likes(self, post_id, selectors=None, params=None,
headers=None):
url = '%s/~/network/updates/key=%s/likes' % (ENDPOINTS.PEOPLE, post_id)
if selectors:
url = '%s:(%s)' % (url, LinkedInSelector.parse(selectors))

response = self.make_request('GET', url, params=params, headers=headers)
raise_for_error(response)
return response.json()

def comment_as_company(self, company_id, update_key, comment):
comment = {'comment': comment}
url = '%s/updates/key=%s/update-comments-as-company' % (
ENDPOINTS.COMPANIES, company_id, update_key)
response = self.make_request('PUT', url, data=json.dumps(comment))
raise_for_error(response)
return True