17

I want to display to know when the facebook like button is clicked and upon verify button click, I want to post the like to the fan page. I want to use Facebook C# SDK. Here is my code:

Html

<html>
<head>
  <title>Your Website Title</title>
    <!-- You can use open graph tags to customize link previews.
    Learn more: https://developers.facebook.com/docs/sharing/webmasters -->
  <meta property="og:url"           content="https://www.your-domain.com/your-page.html" />
  <meta property="og:type"          content="website" />
  <meta property="og:title"         content="Your Website Title" />
  <meta property="og:description"   content="Your description" />
  <meta property="og:image"         content="https://www.your-domain.com/path/image.jpg" />
</head>
<body>
  <button id="btnVerify">Verify</button>
  <!-- Load Facebook SDK for JavaScript -->
  <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 = "https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.0";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));</script>

  <!-- Your like button code -->
  <div class="fb-like" 
    data-href="https://www.your-domain.com/your-page.html" 
    data-layout="standard" 
    data-action="like" 
    data-show-faces="true">
  </div>

</body>
</html>

Javascript

<script>
var liked_page = function() {
  alert("liked!");
}

FB.Event.subscribe('edge.create', liked_page);
</script>

Here I am using Javascript SDK but edge.create is depecreated. How to acheive the same using C# SDK. Please share your insights.

Pearl
  • 8,373
  • 8
  • 40
  • 59
  • 3
    sounds super-spammy, why would people want to see a post on a page for every new like? anyway, what you want to achieve is not possible. as you found out already, edge.create is deprecated. you will never get the user_likes permissions approved for those kind of things, and that would be the only way - each user who liked your page would have to authorize your app for that as well. – andyrandy Sep 25 '18 at 10:09
  • 2
    btw, that´s not jquery, that´s simple javascript. just saying ;) – andyrandy Sep 25 '18 at 10:11
  • @luschn Okay, let's say User has logged in to the Facebook and gave permissions to our website – Pearl Sep 25 '18 at 10:28
  • still, you would need to go through the review process. and facebook would definitely not approve it for something like that. you can try, of course. – andyrandy Sep 25 '18 at 10:45
  • @luschn There are many websites implementing that like you can check followlike.com – Pearl Sep 25 '18 at 11:23
  • "This Domain May Be For Sale" - nope ;) – andyrandy Sep 25 '18 at 11:32
  • it's followlike.net – Pearl Sep 28 '18 at 16:30
  • that page is highly illegal, they say they do not sell likes, but they also write the exact opposite: "Simply add your Link or Social Account. Offer a bid, then people will follow, like, view or share your content if they wish" - selling likes is not allowed. btw, they are not using an app for this, as it seems. it works completely different from what you are trying to achieve. – andyrandy Sep 30 '18 at 14:30
  • 2
    It is not clear what you're asking. Please be more specific regarding your question. – Matt Oct 08 '18 at 14:03
  • In order to achive this goal you can use Webhooks. Please see: https://developers.facebook.com/docs/graph-api/webhooks/ – Basil Kosovan May 28 '19 at 14:26

2 Answers2

1

...upon verify button click, I want to post the like to the fan page

That´s done automatically with the Like Button. If you want to check if someone liked your Page right after using the Like Button, be aware that Like Gating is not allowed and the edge.create event is deprecated.

The only way to detect if a User (currently) likes your Page is to use the /me/likes endpoint of the Graph API with the user_likes permission. You have to go through Facebooks review process in order to use that permission, so make sure to read the platform policy first: https://developers.facebook.com/policy/

andyrandy
  • 72,880
  • 8
  • 113
  • 130
0

Facebook SDK for C# relies on GRAPH API, meaning it is here to help you use the GRAPH API much more easily.

You can find the documentation regarding likes in this Link:

You can get a list of pages the person liked but you cannot create likes (for example, pressing like).

Facebook removed this functionality so as of now, the only way to simulate like for the user is through facebook itself, meaning:

You will not be able to create the like functionality unless you redirect to facebook itself.

Barr J
  • 10,636
  • 1
  • 28
  • 46