如何使用angularJS / javascript在Twitter上分享帖子以及帖子详细信息

时间:2019-02-27 20:41:30

标签: javascript html angularjs twitter twitter-share

我已经使用AngujarJS / JavaScript技术(前端)创建了一个网站。

如何在Twitter上分享帖子?

我在index.html中创建了元数据,需要共享帖子的详细信息。当我单击Twitter按钮时,应在JavaScript方法 shareOnTW * $ scope.shareOnTW = function(imgs)

上单击该按钮

$scope.shareOnTW = function(imgs){
    // Opens a pop-up with twitter sharing dialog
    var shareURL = "http://twitter.com/share?"; //url base
    //params
    var params = {      		
        'og:url': "https://krishnafortoday.com/#/newart?rt="+imgs.artId// url to share
	}
    for(var prop in params) 
	    shareURL += '&' + prop + '=' + encodeURIComponent(params[prop]);
    window.open(
        shareURL,
        '',
        'left=450,top=200,width=550,height=450,personalbar=0,toolbar=0,scrollbars=0,resizable=0'
    );
}
<head> 

<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@TodayKrishna">
<meta name="twitter:creator" content="@TodayKrishna">
<meta property="og:url" content="https://Krishnafortoday.com/" />
<meta property="og:title" content="Krishna for Today:" />
<meta property="og:description" content="The website https://krishnafortoday.com is owned and operated by Krishna for Today. It is a registered partnership firm that has the exclusive copy rights over all the works of art/prints/books or any other media created by Keshav. The GST number is 29AAQFK7520F1Z1. Our principal place of business is Bangalore The complete address and contact details are given below." />
<meta property="og:image" content="https://res.cloudinary.com/kftcloudcloudinary/image/upload/f_auto/q_auto/c_lpad,h_600,w_600/v1547058506/orgImages/180408_Yashodas_Universe" />

</head>

<button class="fb-xfbml-parse-ignore" target="_blank" ng-click="shareOnTW(imgs)">

<img class="YOUR_FB_CSS_STYLING_CLASS" src="img/twt.png" width="22px" height="22px" alt="">
</button>

Screenshot of website

0 个答案:

没有答案