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.
Clicking Like below a post on Facebook is a way to let people know that you enjoy it without leaving a comment. Just like a comment, anyone who can see the post can see that you liked it. For example, if you click Like below a friend's video: People who can see the video will be able to see that you liked it.
...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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With