def upload_image_to_feed(client: ApiClient, image_path: str, caption: str = None, location: ps.Location = None) -> bool: """Upload an image to your feed. Location and caption are optional. Args: client: your `ApiClient` image_path: path to the image to upload caption: the caption of the post location: the location tag of the post Returns: `True` if success else `False` """ post = ps.PostFeed( path=image_path, caption=caption or '', location=location, ) resp = client.post_post(post, 80).ok logger.info(f"Uploaded image to feed") return is_resp_ok(resp)
import os from instauto.api.client import ApiClient from instauto.api.actions import post as ps if __name__ == '__main__': if os.path.isfile('./.instauto.save'): client = ApiClient.initiate_from_file('./.instauto.save') else: client = ApiClient(username=os.environ.get("INSTAUTO_USER") or "your_username", password=os.environ.get("INSTAUTO_PASS") or "your_password") client.log_in() client.save_to_disk('./.instauto.save') post = ps.PostStory(path='./test_story.jpg', ) resp = client.post_post(post, 80) print("Success: ", resp.ok)
def upload_image_to_story(client: ApiClient, image_path: str) -> bool: post = ps.PostStory(path=image_path) resp = client.post_post(post) logger.info(f"Uploaded image to story") return is_resp_ok(resp)
def upload_image_to_story(client: ApiClient, image_path: str) -> bool: post = ps.PostStory(path=image_path) resp = client.post_post(post) return is_resp_ok(resp)