使用javascript django的图像的推特的工作示例 [英] working example of tweet with image using javascript django

查看:191
本文介绍了使用javascript django的图像的推特的工作示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < meta name =twitter:cardcontent =summary_large_image> 
< meta name =twitter:sitecontent =http://203.110.93.244/>
< meta name =twitter:creatorcontent =@ SarahMaslinNir>
< meta name =twitter:titlecontent =休斯顿葬礼的粉丝游行>
< meta name =twitter:descriptioncontent =NEWARK - 这里的客串名单和豪华轿车witproject的游行。>
< meta name =twitter:imagecontent =http://www.promon.in/media/images/products/2015/09/listing_image_vsRFOqw.jpg>

然后我用这个javascript来鸣叫:

  twttr.widgets.createShareButton(
'http://203.110.93.244/offers/eat-n-drink/Delhi-greater-kailash-rara-avis/81/ ',
document.getElementById('twitter-btn'),
{
text:'#HelloWorld',
});

问题是,我没有得到任何图像缩略图。
请指导我走一条可行的解决方案。
谢谢。

解决方案

以下内容对我有用。当用户点击按钮时,它会打开一个窗口...它会发送源页面的URL,这是您的Twitter用户名的via和您要显示的任何消息的文本。请注意,文本数量有限,如果太长的Twitter默默地删除了部分数据。



图像的页面URL必须先显示。您可以在此测试页面的有效性: https://cards-dev.twitter.com/validator

  jQuery(#twitter-share-button)点击(function(e)
{
e.preventDefault();

var uri =http://203.110.93.244/offers/eat-n-drink/Delhi-greater-kailash-rara-avis/81/ ;
var tweet =https://twitter.com/intent/tweet?url=
+ encodeURI(uri)
+& via = yourtwittername& text =
+ encodeURI(uri)
+ encodeURI(#your-hash-tag)
+ encodeURI(some more text here);
window.open(tweet,Share在Twitter上);
});


I am trying to tweet with image using javascript.I read about cards, and put the following on page i am sharing:

<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="http://203.110.93.244/">
<meta name="twitter:creator" content="@SarahMaslinNir">
<meta name="twitter:title" content="Parade of Fans for Houston’s Funeral">
<meta name="twitter:description" content="NEWARK - The guest list and parade of limousines witproject here.">
<meta name="twitter:image" content="http://www.promon.in/media/images/products/2015/09/listing_image_vsRFOqw.jpg">

then i use this javascript to tweet:

twttr.widgets.createShareButton(
        'http://203.110.93.244/offers/eat-n-drink/Delhi-greater-kailash-rara-avis/81/',
        document.getElementById('twitter-btn'),
        {
            text: '#HelloWorld',
        });

Problem is, I am not getting any image thumbnail. Please guide me towards a viable solution. Thanks.

解决方案

Something as follows works for me. It opens a window whenever the user clicks a button... It sends the "URL" of the source page, "via" which is your twitter username, and "text" which is whatever message you want to appear in there. Note that the amount of text is limited and if too long Twitter silently eliminate part of the data.

The page URL with the image must appear first. You can test the validity of the page here: https://cards-dev.twitter.com/validator

jQuery("#twitter-share-button").click(function(e)
  {
    e.preventDefault();

    var uri = "http://203.110.93.244/offers/eat-n-drink/Delhi-greater-kailash-rara-avis/81/";
    var tweet = "https://twitter.com/intent/tweet?url="
          + encodeURI(uri)
          + "&via=yourtwittername&text="
          + encodeURI(uri)
          + encodeURI(" #your-hash-tag ")
          + encodeURI("some more text here");
    window.open(tweet, "Share on Twitter");
  });

这篇关于使用javascript django的图像的推特的工作示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆