omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Can we tweet with selected photos?

    Pythonista
    twitter
    1
    1
    1643
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • kickbase
      kickbase last edited by kickbase

      I don't know how to post tweet with selected photos.
      Please help me.
      Thanks.

      import twitter, ui, dialogs, console,photos
      
      def tweet(account,text,param=None):
          if len(text) < 140:
              twitter.post_tweet(account, text, parameters=param)
              console.hud_alert('Tweet Posted', 'success', 1.5)
          else:
              console.hud_alert('Exceeded Character Limit', 'error', 1.5)
      
      assets = photos.pick_asset(title='Pick Some Assets', multi=False)
      params={
          'media_id_string':assets.local_id,
          'image_type':assets.media_type,
          'image':{
              'w':assets.pixel_width,
              'h':assets.pixel_height
          }
      }
      
      all_accounts = twitter.get_all_accounts()
      if len(all_accounts) >= 1:
          account = all_accounts[0]
          text = dialogs.text_dialog(title='Input Tweet')
          if text:
              tweet(account,text+' #my_hash_tag',params)
          else:
              console.hud_alert('User Canseled')
      
      1 Reply Last reply Reply Quote 1
      • First post
        Last post
      Powered by NodeBB Forums | Contributors