简体   繁体   中英

How do I let a user tweet an image?

We have a twitter button set up where users click on it and a popup opens up to let the user tweet from their own account. How can we include an image with that tweet? (With facebook we've been able to do it).

<div>

   <a href="http://twitter.com/share" class="twitter-share-button"
      data-url="http://www.mysite.com"
      data-text="sharing this with you...."
      data-count="none">Tweet</a>
</div>



<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
  <script type="text/javascript">
 twttr.events.bind('tweet', function(event) {
       window.location = "http://www.mysite.com"

    });

</script>

To do this, you'll need to use the API directly (not just their widget). Details on how to post with a media item can be found at the status/update_with_media docs.

If you're looking for a kind of rendering a 'preview' of a link (what Facebook allows through Open Graph), then checkout the Cards documentation.

You can also use the following:

https://dev.twitter.com/rest/media/uploading-media

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM