def upload_image_to_feed(client: ApiClient, image_path: str, caption: str = None, location: ps.Location = None) -> bool: post = ps.PostFeed( path=image_path, caption=caption or '', location=location, ) resp = client.post_post(post, 80).ok return is_resp_ok(resp)
def upload_image_to_feed(client: ApiClient, image_path: str, caption: Optional[str] = None, location: Optional[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) logger.info(f"Uploaded image to feed") return is_resp_ok(resp)
client = ApiClient(user_name=os.environ.get("INSTAUTO_USER") or "your_username", password=os.environ.get("INSTAUTO_PASS") or "your_password") client.login() client.save_to_disk('./.instauto.save') # Any of the below examples will work. # ps.UserTag defines a single usertag # ps.UserTags takes all usertags in a list and could be given to the ps.PostFeed usertag1 = ps.UserTag( user_id="", # user_id of user you want to tag x=0.2, # relative x coordinate with 0<=x<=1, with 0 for left and 1 for right y=0.2 # relative y coordinate with 0<=x<=1, with 0 for top and 1 for bottom ) usertags = ps.UserTags( usertags=[usertag1] ) posts = [ ps.PostFeed( path='./test_feed.jpg', caption='This is an example. Follow me!', usertags=usertags ), ps.PostFeed( path='./test_feed.jpg', caption='Another post', usertags=usertags ) ] resp = client.post_carousel(posts, "Caption", 80) print("Success: ", resp['configure_sidecar'].ok)
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(user_name=os.environ.get("INSTAUTO_USER") or "your_username", password=os.environ.get("INSTAUTO_PASS") or "your_password") client.login() client.save_to_disk('./.instauto.save') # Any of the below examples will work. # location = ps.Location(lat=38.897699584711, lng=-77.036494857373) # location = ps.Location(name="The white house") location = ps.Location(lat=68.14259, lng=148.84371, name="The white house") post = ps.PostFeed(path='./test_feed.jpg', caption='This is an example. Follow me!', location=location) resp = client.post_post(post, 80) print("Success: ", resp.ok)
#info_id = client.profile_info(i_id) #print(info_id) # In[54]: img # In[454]: post = ps.PostFeed( path=name, caption=caption ) resp = client.post_post(post, 80) print("Success: ", resp.ok) post = ps.PostStory( path=storyname, ) resp = client.post_post(post, 80) print("Success: ", resp.ok) # In[399]: