Javascript 如何在一张卡片中将我的网页共享到twitter

Javascript 如何在一张卡片中将我的网页共享到twitter,javascript,html,twitter,Javascript,Html,Twitter,我已经按照中的指导做了,但它不像把我的图片和描述放在一张卡片上分享给其他人那样有效 我想在twitter的卡片上分享我的网页 <meta name="twitter:card" content="summary" /> <meta name="twitter:title" content="summary" /> <meta name="twitter:creator" content="summary" /> <meta name="twitter:i

我已经按照中的指导做了,但它不像把我的图片和描述放在一张卡片上分享给其他人那样有效

我想在twitter的卡片上分享我的网页

<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="summary" />
<meta name="twitter:creator" content="summary" />
<meta name="twitter:image" content="https://stackoverflow.com/questions/56339282/how-to-share-my-webpage-to-twitter-in-a-card/are_6b65b534.jpg" />
<meta name="twitter:description"   content="@ViewBag.Description" />

当我把指南代码放在我的网页上时,我仍然在分享我的网页时得到一个url


感谢您的帮助。

请添加属性属性,如:

<meta property="og:url" content="http://bits.blogs.nytimes.com/2011/12/08/a-twitter-for-my-sister/" />
<meta property="og:title" content="A Twitter for My Sister" />
<meta property="og:description" content="In the early days, Twitter grew so quickly that it was almost impossible to add new features because engineers spent their time trying to keep the rocket ship from stalling." />
<meta property="og:image" content="http://graphics8.nytimes.com/images/2011/12/08/technology/bits-newtwitter/bits-newtwitter-tmagArticle.jpg" />


请参考twitter上的示例,使用卡片优化推文。还可以尝试添加图像的完整路径(如示例)和描述标签中的完整内容。

您必须声明图像的完整URL才能正常工作。在此处测试:

可能您的图像URL错误?您是否尝试过这样的外部图像:,也许您需要将summary更改为summary\u large\u图像,并在那里添加twitter:url。@ZiedHf是的,我尝试过,它也不起作用。图像必须是url,而不是路径。另外,您可能会遇到缓存问题,这样对该信息的更改就不会被Twitter重新加载。@str谢谢,我想让它变得简单,所以我随意地填充图像内容ψ(.。)>以及如何清理缓存我刚开始试过这个代码,嗯,但它不起作用。是关于robot.txt的吗?它表明了这一点“错误:获取页面失败,因为robots.txt拒绝了它。”在[我在手机上尝试了它。是的,如果你的robots.txt文件拒绝访问Twitterbot爬虫程序,这将失败。嗯,我的服务器中没有robots.txt。它仍然阻止访问吗?