无需卡即可将图像分享到 Twitter
Share Image to Twitter without Card
给定某个地址的图像,http://www.thissite.will/never/be-finished.png
,将其分享到 Twitter 的最简单方法是什么,最好没有卡片?
用户自定义 SVG,当他们满意时,我将其转换为 PNG 并将其存储在我的服务器上。
我想让他们选择在 Twitter 上分享图片。他们单击一个按钮(我可以实现),然后会打开一个对话框,他们可以在其中添加到推文(应该已经包含图片)。
我知道以前有人在这个网站上问过类似的问题,但我不想想使用"card"分享图像。相反,我想要一个典型的非卡片推文,只有一张图片(比如 this)。
我反复查看了 Twitter 开发者文档,但找不到有用的信息。 POST statuses/update_with_media method is deprecated, and the link to the "Uploading Media Guide," a suggested replacement, is broken. This guide,我假设,是它打算 link 到 但它没有 JavaScript 代码来建议应该如何实际实现 .
请帮忙
我的尝试,基于 POST media/upload
:
$.ajax({
url: "https://upload.twitter.com/1.1/media/upload.json",
format: "post",
data: {"data" : link}
}).success(function(response) {
console.log(":)");
console.log(response);
}).fail(function(response) {
console.log(":(");
console.log(response.responseText);
});
这失败了。 responseText
是 {"errors":[{"code":215,"message":"Bad Authentication data."}]}
.
基本上,我想做一些类似于 Whosebug 所做的事情。当您在问题上单击 "share",然后单击 select Twitter 时,会弹出一个新的 window,其中填充了问题的 link,用户可以在其中编写自己的消息。 (Twitter 提供接口。)
然而,在我的情况下,当推文被发送时,而不是 link 回到页面并从中提取一些文本,我只想有一张图片。
Twitter 没有官方的图片分享方式。你必须使用Twitter card. This is my one webpage with nice image. Test that URL on Twitter card validator, you'll get quite image. That is like your example with Bloomberg's twitter status link. Now you can click this link to tweet which is of my that webpage(当然你可以删除那条推文,它是测试的例子)。您将获得带有自定义文本选项的大图像。这些都是你想要的。
以上推特分享hyperlink的参数
我给你的 hyperlink 是这样的:
https://twitter.com/intent/tweet?text=Cheapest%20CDNs%20With%20HTTPS%2C%20IPv6%2C%20HTTP%2F2%2C%20Brotli&url=https%3A%2F%2Fthecustomizewindows.com%2F2017%2F06%2Fcheapest-cdns-https-ipv6-http2-brotli%2F&hastag=AbhishekGhosh&via=AbhishekCTRL&original_referer=https%3A%2F%2Fthecustomizewindows.com%2F2017%2F06%2Fcheapest-cdns-https-ipv6-http2-brotli%2F
https://twitter.com/intent/tweet
是常量部分。 ?text=
是你想要的文字。 &url=
是 URL 您将分享。 &via=
是可选的关联帐户。 &original_referer=
在大多数情况下与&url=
相同,&hashtags
是您想要的人质。 &hashtags
不起作用。
但是你想要它用于图像而不是网页。这很棘手。
你需要什么
你想要的需要有PHP-MySQL之类的网络软件。应用程序将为用户生成的带图像的网页编写一个独特的 URL 加班用户完成工作,并为 Twitter 卡片添加 HTML 标记。 Twitter 卡片与网页如何具有标记、图像、域的网站管理员设置等有关。您可以使用 PHP 之类的语言通过网页的 HTML 标记设置首选图像。
原型应用示例
作为使用 WordPress 开发的想法的一个例子,当我没有发表文章时,我有图像,但 URL 预览是私人的。在 WordPress 中可以使未发表文章的public。可以用 4 个 WordPress 插件作为基本示例进行测试:
- https://wordpress.org/plugins/public-post-preview/(使未发布的 post 有一个 public 预览)
- https://wordpress.org/plugins/developer-share-buttons/(生成推特分享 link)
- https://wordpress.org/plugins/twitter-cards-meta/(生成推特元标签)
- https://wordpress.org/plugins/live-composer-page-builder/(为注册用户提供一种在 WordPress 前端进行编辑的方式)
当然有更新的 WordPress API 可以在其他服务器上进行。
给定某个地址的图像,http://www.thissite.will/never/be-finished.png
,将其分享到 Twitter 的最简单方法是什么,最好没有卡片?
用户自定义 SVG,当他们满意时,我将其转换为 PNG 并将其存储在我的服务器上。
我想让他们选择在 Twitter 上分享图片。他们单击一个按钮(我可以实现),然后会打开一个对话框,他们可以在其中添加到推文(应该已经包含图片)。
我知道以前有人在这个网站上问过类似的问题,但我不想想使用"card"分享图像。相反,我想要一个典型的非卡片推文,只有一张图片(比如 this)。
我反复查看了 Twitter 开发者文档,但找不到有用的信息。 POST statuses/update_with_media method is deprecated, and the link to the "Uploading Media Guide," a suggested replacement, is broken. This guide,我假设,是它打算 link 到 但它没有 JavaScript 代码来建议应该如何实际实现 .
请帮忙
我的尝试,基于 POST media/upload
:
$.ajax({
url: "https://upload.twitter.com/1.1/media/upload.json",
format: "post",
data: {"data" : link}
}).success(function(response) {
console.log(":)");
console.log(response);
}).fail(function(response) {
console.log(":(");
console.log(response.responseText);
});
这失败了。 responseText
是 {"errors":[{"code":215,"message":"Bad Authentication data."}]}
.
基本上,我想做一些类似于 Whosebug 所做的事情。当您在问题上单击 "share",然后单击 select Twitter 时,会弹出一个新的 window,其中填充了问题的 link,用户可以在其中编写自己的消息。 (Twitter 提供接口。)
然而,在我的情况下,当推文被发送时,而不是 link 回到页面并从中提取一些文本,我只想有一张图片。
Twitter 没有官方的图片分享方式。你必须使用Twitter card. This is my one webpage with nice image. Test that URL on Twitter card validator, you'll get quite image. That is like your example with Bloomberg's twitter status link. Now you can click this link to tweet which is of my that webpage(当然你可以删除那条推文,它是测试的例子)。您将获得带有自定义文本选项的大图像。这些都是你想要的。
以上推特分享hyperlink的参数
我给你的 hyperlink 是这样的:
https://twitter.com/intent/tweet?text=Cheapest%20CDNs%20With%20HTTPS%2C%20IPv6%2C%20HTTP%2F2%2C%20Brotli&url=https%3A%2F%2Fthecustomizewindows.com%2F2017%2F06%2Fcheapest-cdns-https-ipv6-http2-brotli%2F&hastag=AbhishekGhosh&via=AbhishekCTRL&original_referer=https%3A%2F%2Fthecustomizewindows.com%2F2017%2F06%2Fcheapest-cdns-https-ipv6-http2-brotli%2F
https://twitter.com/intent/tweet
是常量部分。 ?text=
是你想要的文字。 &url=
是 URL 您将分享。 &via=
是可选的关联帐户。 &original_referer=
在大多数情况下与&url=
相同,&hashtags
是您想要的人质。 &hashtags
不起作用。
但是你想要它用于图像而不是网页。这很棘手。
你需要什么
你想要的需要有PHP-MySQL之类的网络软件。应用程序将为用户生成的带图像的网页编写一个独特的 URL 加班用户完成工作,并为 Twitter 卡片添加 HTML 标记。 Twitter 卡片与网页如何具有标记、图像、域的网站管理员设置等有关。您可以使用 PHP 之类的语言通过网页的 HTML 标记设置首选图像。
原型应用示例
作为使用 WordPress 开发的想法的一个例子,当我没有发表文章时,我有图像,但 URL 预览是私人的。在 WordPress 中可以使未发表文章的public。可以用 4 个 WordPress 插件作为基本示例进行测试:
- https://wordpress.org/plugins/public-post-preview/(使未发布的 post 有一个 public 预览)
- https://wordpress.org/plugins/developer-share-buttons/(生成推特分享 link)
- https://wordpress.org/plugins/twitter-cards-meta/(生成推特元标签)
- https://wordpress.org/plugins/live-composer-page-builder/(为注册用户提供一种在 WordPress 前端进行编辑的方式)
当然有更新的 WordPress API 可以在其他服务器上进行。