Twitter - 分享按钮,但有图片 [英] Twitter - share button, but with image
问题描述
我想使用本页上的常规分享按钮https://twitter.com/about/resources/buttons#tweet 但要从我的网站添加嵌入的图像,而不仅仅是链接.
I want to use regular share button like on this page https://twitter.com/about/resources/buttons#tweet but to add an embedded image from my site, not just link.
我对 1.1 api 和上传都了如指掌,但是制作一个 tw 应用程序然后要求访问者在我的网站上允许在他的时间轴上写文章只是为了分享我网站上的一张图片是不可能的场景,所以我考虑了替代方案.
I know all about 1.1 api and uploading, but making an tw application and then ask visitor on my site to give permission to write on his timeline just to share one pic from my site is not likely scenario, so I think about alternatives.
我注意到当只是将已经在 Twitter 上上传的图片链接粘贴到推文中时,如果您粘贴像 https://pbs.twimg.com/media/BPpk_KUCMNBXsPN.jpg
这样的链接不会被嵌入,但如果你粘贴这样的链接 pic.twitter.com/NuDSx1ZKwy
它将被嵌入.所以我想如果我制作的个人资料和应用程序将调用 https://upload.twitter.com/1/statuses/update_with_media.json
并上传图片,然后将链接粘贴到分享按钮中,我会得到嵌入图片的推文.或者有更好的方法吗?我用的是php.
I've noticed when just paste links of pic that are already uploaded on twitter into tweet, if you paste link like https://pbs.twimg.com/media/BPpk_KUCMNBXsPN.jpg
that is not going to be embeded, but if you paste link like this pic.twitter.com/NuDSx1ZKwy
it will be embeded. So I think if I make profile and app that will call https://upload.twitter.com/1/statuses/update_with_media.json
and upload pic, and then paste link in share button I will get tweet with pic embeded. Or there is better way? I use php.
推荐答案
查看 twitter 卡片.
诀窍不在于按钮,而在于您共享的页面.Twitter Cards 从类似于 facebook
分享的元标签中提取图像.
The trick is not in the button but rather the page you are sharing. Twitter Cards pull the image from the meta tags similar to facebook
sharing.
示例:
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@site_username">
<meta name="twitter:title" content="Top 10 Things Ever">
<meta name="twitter:description" content="Up than 200 characters.">
<meta name="twitter:creator" content="@creator_username">
<meta name="twitter:image" content="http://placekitten.com/250/250">
<meta name="twitter:domain" content="YourDomain.com">
这篇关于Twitter - 分享按钮,但有图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!