I am currently working on a website, on this website I have a Facebook share button and a Twitter tweet button. Then I have a javascript variable set to 0, now the problem I am having is that I would like to check if a person has shared on Facebook and made a tweet on Twitter by increasing the variable by 1 for when sharing on Facebook and increasing by 1 when tweeting and then if the variable is 2 then I would like to create a pop up.

我目前正在一个网站上工作,在这个网站上我有一个Facebook分享按钮和一个Twitter推特按钮。然后我有一个javascript变量设置为0,现在我遇到的问题是我想检查一个人是否已经在Facebook上分享并在Twitter上发布推文,在Facebook上分享增加变量1并增加1当发推特然后如果变量是2那么我想创建一个弹出窗口。

I have gotten this which is the Facebook button

我得到了这个Facebook按钮

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/da_EN/sdk.js#xfbml=1&version=v2.5";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

Then I have the tweet button

然后我有推文按钮

<div id="twitbut">
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://weiskleint.com/" data-text="Sign up for this awesome brand launching soon!" data-via="Weiskleint" data-hashtags="weiskleint">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
</div>  

And lastly the Javascript variable which I have in the same html script

最后是我在同一个html脚本中的Javascript变量

 <script type="text/javascript">
            var shares=0;

            if (shares == 2)

        </script>

My issue is that I am not really sure how to check if a person has shared on Facebook or Twitter, but I would think I have to get the variable in the button codes and then when a person clicks that button it would increase the variable. But then if I were to do it like this, wouldn't you just have to click the button and then the person doesn't have to share the actual post? which is kind of the goal.

我的问题是我不确定如何检查一个人是否在Facebook或Twitter上分享,但我认为我必须在按钮代码中获取变量,然后当一个人点击该按钮时它会增加变量。但是如果我这样做的话,你不是必须点击按钮然后这个人不必分享实际的帖子吗?这是一种目标。

I am sorry if it is a bit cluttered, but in simple what I want to do is ask the user to share on both Facebook and Twitter and if the person does this they are rewarded with a coupon code. This code would then be in a pop up.

我很抱歉,如果它有点混乱,但简单地说我要做的是要求用户在Facebook和Twitter上分享,如果这个人这样做,他们会得到优惠券代码。这段代码将弹出。

Thanks in advance.

提前致谢。

1 个解决方案

#1


2

The method based on subscribing to the click event on the buttons is not reliable. You absolutely do not know if the user did or didn't like your page.

基于订阅按钮上的点击事件的方法是不可靠的。你绝对不知道用户是否喜欢你的页面。

If you do it for business purpose, please stop!

如果您是出于商业目的,请停止!

The only safe way to know if the user did like your page is by having him authenticate via facebook/twitter, then ask their apis.

了解用户是否喜欢您的网页的唯一安全方法是让他通过Facebook / Twitter进行身份验证,然后询问他们的api。

I think you should take a look to : https://developers.facebook.com/docs/graph-api/reference/user/likes/

我想你应该看看:https://developers.facebook.com/docs/graph-api/reference/user/likes/

更多相关文章

  1. html5中点击按钮,改变按钮状态效果样式
  2. 组合两个下拉菜单以确定提交按钮链接
  3. 设计不是使用跨度和按钮
  4. 使用下一个div中的文本设置“下一个”按钮的文本
  5. 更改在表Django中选择了其中一个按钮时显示的状态
  6. 仅使用CSS / HTML将鼠标悬停在按钮上时显示div
  7. JSP 或HTML 如何通过button按钮转到想去的页面
  8. 如何将标记中的值传递给PHP变量?
  9. HTML5按钮元素新属性formaction,formenctype等简介

随机推荐

  1. Android(安卓)ViewStub控件使用
  2. android 禁止横切屏的代码
  3. android代码格式化方法小结
  4. android 笔记-scrollview滑动阴影取消
  5. Android摄像头相关问题记录
  6. android自动获取短信验证码
  7. 旋转对话框
  8. 【Android】Android中AlertDialog对话框
  9. Android7.0中文文档(API) -- EdgeEffect
  10. Android(六): What Android Is