-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinkedInPostAPI.py
More file actions
36 lines (25 loc) · 1.19 KB
/
Copy pathlinkedInPostAPI.py
File metadata and controls
36 lines (25 loc) · 1.19 KB
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
import requests
organization_id = '40759021'
#scope: w_member_social,r_liteprofile,w_organization_social
access_token = 'AQWcdbfGJzdwD_0CwFzxabj5b0rx-5Cc3CSyFk5baTDvRf7l4JAcUpgaXeHDFSW4GeOFMbkhvGzEtzRhdQu1kMNEWobPoTnjUIuVklXzitEoH9cEaLTJiraHAS999ImM3HILURa_AJXHZ_2x_lsDtlL-J6jcRB8KGy8ZC05YehWIZE75kLd_5x1kHm0VxUpXt8LngueW3YMiBm_DSdXozmpGJTLwE4oFscHn0Db6j1lwbBsRfH8AErV6Vws-XctbbCx3ZdVkrvRhTV3WM0wqQw-WcTlfnTc7X4Evts3iiSzZYBqbF-UZlZHft7AAqvVKpSwBkehgeAHyt6aRiyJFFhtQltTgRg'
url = "https://api.linkedin.com/v2/ugcPosts"
headers = {'Content-Type': 'application/json',
'X-Restli-Protocol-Version': '2.0.0',
'Authorization': 'Bearer ' + access_token}
post_data = {
"author": "urn:li:organization:"+organization_id,
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "Hello World! This is my first Share on LinkedIn from my organization!"
},
"shareMediaCategory": "NONE"
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}
response = requests.post(url, headers=headers, json=post_data)
print(response)