File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 1+ import requests
2+
3+ def get_linkedin_posts (access_token ):
4+ url = 'https://api.linkedin.com/v2/shares?q=owners&owners=urn:li:person:YOUR_USER_ID&count=10'
5+ headers = {'Authorization' : f'Bearer { access_token } ' }
6+
7+ response = requests .get (url , headers = headers )
8+ data = response .json ()
9+
10+ if response .status_code == 200 :
11+ posts = data .get ('elements' , [])
12+ for post in posts :
13+ post_text = post .get ('text' , '' )
14+ print (post_text )
15+ else :
16+ print (f"Error: { response .status_code } - { data .get ('message' , 'Unknown error' )} " )
17+
18+ if __name__ == "__main__" :
19+ # Replace YOUR_ACCESS_TOKEN and YOUR_USER_ID with appropriate values
20+ access_token = "YOUR_ACCESS_TOKEN"
21+ get_linkedin_posts (access_token )
You can’t perform that action at this time.
0 commit comments