javascript - 如何使用 angularJS/javascript 在 Twitter 上分享帖子以及帖子详细信息
问题描述
我使用 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>
解决方案
推荐阅读
- php - 如何修复“重定向你太多次”。
- c - 默认安装的 Code::Blocks 在程序结束时不会因“按任意键继续”而暂停
- c - “UA_ReadRequest_deleteMembers”错误问题的 OPC-UA 函数
- python - 从python检测macos中的暗模式
- xamarin - Cocossharp 精灵掩蔽
- python - 如何在嵌套字典中查找重复项或重复项?
- php - 在 RESTful API 中重写 URL
- java - Runtime.exec 不会运行 javac,但命令行会
- r - 在 r 中创建一个稀疏矩阵,每行具有一组整数值
- javascript - 未运行 Jest+Enzyme API 模拟调用测试