hootsuiterestapi的python库。
hootsweet的Python项目详细描述
^{1}$
hootsuiterestapi的python API。在
安装
pip install hootsweet
使用
^{pr2}$消息
token={"access_token":"e9a90a81-xf2d-dgh3-cfsd-23jhvn76","token_Type":"Bearer","expires_in":2592000,"refresh_token":"82d82cf4-76gf-gfds-nt3k-lzpo12jg","scope":"offline"}client=HootSweet("client_id","client_secret",token=token)# Schedule a messagetext="A message"social_profile_ids=["1234","12345"]send_time=datetime(2020,1,1,12,40,15)message=client.schedule_message(text=text,social_profile_ids=social_profile_ids,send_time=send_time)# Get messagemessage=client.get_message(message_id="98765")# Delete messageclient.delete_message(message_id="98765")
媒体消息
HootSuite使用自己的AWS存储桶向消息添加媒体。到 将媒体附加到您需要先上载媒体的邮件 去HootSuite的水桶。在
token={"access_token":"e9a90a81-xf2d-dgh3-cfsd-23jhvn76","token_Type":"Bearer","expires_in":2592000,"refresh_token":"82d82cf4-76gf-gfds-nt3k-lzpo12jg","scope":"offline"}client=HootSweet("client_id","client_secret",token=token)mime_type="image/png"file_path=Path("/path/to/file.png")file_size=file_path.stat().st_sizeupload_details=client.create_media_upload_url(file_size,mime_type)upload_url=upload_details["uploadUrl"]media_id=upload_details["id"]# The number of seconds you have to upload the mediaexpires_in=upload_details["uploadUrlDurationSeconds"]# Upload the mediawithfile_path.open("rb")asf:content=f.read()headers={"Content-Type":mime_type,"Content-Length":str(file_size)}# Make sure that this request returns a 200requests.put(upload_url,headers=headers,data=content)# Schedule a messagetext="A message"social_profile_ids=["1234","12345"]send_time=datetime(2020,1,1,12,40,15)media=[{"id":media_id}]message=client.schedule_message(text=text,social_profile_ids=social_profile_ids,send_time=send_time,media=media)
- 项目
标签: