我使用 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>