How to share post on twitter along with post details by using angularJS/javascript

倖福魔咒の 提交于 2019-12-13 17:14:39

问题


I have created a website by using AngujarJS/JavaScript technology (front-end).

How can I share posts on twitter?

I created meta data in index.html, need to share posts details. When I click the twitter button, that button should be hit on JavaScript method 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>

来源:https://stackoverflow.com/questions/54914134/how-to-share-post-on-twitter-along-with-post-details-by-using-angularjs-javascri

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!