Team Ai
Apppublic

Coding-With-Raptor/Likendin-Agent

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
raw_function.cpython-313.pyc38 linesDownload Raw Back to __pycache__
1�

2�a,h�
���SSKJrJr SSKrSSKr\R3"S5r\"\"55 S\3SS.rSrSr	S	r4S5rg)�)�load_dotenv�find_dotenvN�LINKEDIN_ACCESS_TOKEN�Bearer zapplication/json)�
AuthorizationzContent-Typec���Sn[R"U[S9nUR5 UR	5$![R6Ran[SU35 SnAgSnAff=f)z�7Retrieve LinkedIn user profile information using the /userinfo endpoint.8 9Returns:10    dict: User profile information or None if an error occurs.11�$https://api.linkedin.com/v2/userinfo��headers�Error fetching user info: N)�requests�get�HEADERS�raise_for_status�json�12exceptions�RequestException�print)�url�response�es   �Id:\My Own Project\linkedin-agent\backend\mcp_server_tools\raw_function.py�get_user_idrse��1�C���<�<��W�5���!�!�#��}�}�������/�/��
�*�1�#�.�/����s�8=�A3�A.�.A3c��Sn[R"U[S9nURS:XaUR	5$[SUR35 g)z7Retrieve the authenticated user's LinkedIn information.r	r13��rN)r
rr�status_coderr)rrs  r�
get_user_infor#sK��140�C��|�|�C��1�H����s�"��}�}���
�*�8�+?�+?�*@�A�B��c���[5nU(d[S5 gSnSS/SUS3SS	S15./S.0n[R"U[US9nUR16S
:Xa~UR
5RS05RS05RS05RS5UR
5RS05RS54$[SUR1735 g)z'Register an image upload with LinkedIn.z$Failed to retrieve user information.)NNz8https://api.linkedin.com/v2/assets?action=registerUpload�registerUploadRequestz)urn:li:digitalmediaRecipe:feedshare-imagezurn:li:person:�sub�OWNERzurn:li:userGeneratedContent)�relationshipType�18identifier)�recipes�owner�serviceRelationships)rrr�value�uploadMechanismz:com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest�	uploadUrl�assetz Error registering image upload: )rrr
�postrrrr)�	user_infor�payloadrs    r�register_image_uploadr/.s�����I��
�4�5��19D�C��C�D�%�i��&6�%7�8�)0�"?��%�	"20��G��}�}�S�'��@�H����s�"��}�}��"�"�7�B�/�3�3�4E�r�J�N�N�H�"�21�22
�#�k�23�H�M�M�O�/�/���<�@�@��I�J�	J�	�0��1E�1E�0F�G�H�rc��URS5(aL[R"U5nURS:wa[	SUR35 gUR24nO&[
US5nUR5nSSS5 [R"USS	[30WS259nURS:Xa[	S5 g
[	SUR35 g!,(df   Nb=f![a [	SU35 gf=f)z�26Upload the image to LinkedIn.27 28Args:29    upload_url (str): The LinkedIn upload URL30    image_source (str): Either a local file path or a URL to the image31)zhttp://zhttps://rzError fetching image from URL: F�rbNzError: Image file not found at rr)r�data��zImage uploaded successfully.TzError uploading image: )�32startswithr
rrr�content�open�read�FileNotFoundErrorr,r)�33upload_url�image_sourcer�34image_data�35image_files     r�upload_imager=Ks�����6�7�7��<�<��-�����3�&��3�H�4H�4H�3I�J�K���%�%�36�	��l�D�)�Z�'�_�_�.�37�*��}�}�� �G�,A�+B�"C�D�
��H����s�"�
�,�-��
�'��(<�(<�'=�>�?��#*�)�� �	��3�L�>�B�C��	�s0�$C.�0C�C.�38C+�'C.�+C.�.D	�D	)�dotenvrrr
�os�getenvrrrrr/r=�rr�<module>rBsV��+��	��	�	�"9�:���K�M���4�5�6�&����$��:#r