Make FB Like button take user to FB page - facebook

When clicking the Facebook Like button on my site I want the user's browser to be taken to my Facebook page. Is this possible?

This is possible.
If you use the Javascript SDK to subscribe to facebook events http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/
then you subscribe to the edge.create event and then fire some js to do this:
FB.Event.subscribe('edge.create',
function(response) {
window.location = "http://facebook.com/mypage";
}
);
Hope this helps

Related

Capture facebook like/unlike button click event

What is the way of capturing facebook like/unlike click event nowadays? I have old jquery project(no angular or react). I put iframe tag on my web site to render fb like button.
this is not triggering
FB.Event.subscribe('edge.create', function(response) {
alert('You liked the URL: ' + response);
});
edge.create and edge.remove JS SDK Events: These Events will no longer
be accessible. As an alternative, you can use our Webhooks and be
notified every time someone likes one of your Facebook Pages.
Source: https://developers.facebook.com/blog/post/2017/11/07/changes-developer-offerings/
Web Hooks: https://developers.facebook.com/docs/graph-api/webhooks/
Btw, just to be safe: You are not allowed to reward users for liking something, or gate content behind likes.

Facebook: is it possible to track likes for dynamically generated like buttons?

I am dynamically generating Like buttons for an app.
I use FB.XFBML.parse(document.getElementById("fbook"))
and can indeed create likes for dynamic pages. All these likes are then sent to my Facebook App. Is it possible to track which of the pages were liked by users?
You could use this:
FB.Event.subscribe('edge.create',
function(response) {
alert('You liked the URL: ' + response);
}
);
This method attaches an handler to an event and invokes your callback. In the example is the anonymous function.
In this way you can track any like button in page.

Invite friends dialog

I have an invite dialog on my page:
<a href="#" onclick="sendRequestToManyRecipients(); return false;" >xx</a>
<script language="javascript" type="text/javascript">
FB.init({appId : 'myappid', status : true, cookie : true, oauth: true});
function sendRequestToManyRecipients() {
FB.ui({ method: 'apprequests', message: 'xxx'},requestCallback);
}
function requestCallback(response) {
// Handle callback here
}
</script>
When the invited user clicks the invite, he gets linked to the app, but I want the user to get redirected to a page like http://www.facebook.com/pages/xxx/xxx?sk=app_xxxx.
How can I do that?
That's not possible without some custom coding - the requests interface exists to drive traffic to apps on facebook, not to page tabs, there's no way to have Facebook send users to a tab when they accept the request.
You could just implement something on your canvas landing page that redirects users back to a page tab based on the information in the request as a workaround.
previous version of the apprequest which is request-form this was possible: How can I include a link in a FB app request?
However current version of apprequest : facebook guys lets only redirect to your app: https://apps.facebook.com/yourapp
#Vihay comments helps this custom workaround to redirect to page.
Hoping next version apprequests, facebook enables redirect to links within the fb app.
Agree with previous answers. Facebook will redirect to your app, which is just a Facebook wrapper around a page you can provide. That page can then use a client-side redirect to whatever page you'd like (like what Klout does).

Facebook to check "like" on fan page

I noted there is a link to generate "like button" code at :
http://developers.facebook.com/docs/reference/plugins/like/
However it wasn't act as the top of fanpage "like" button which will redirect users to another page if I setup to check the pages liked or not. Is there any other way that I can generate the button as the top of fanpage "like button" behavior or way of using the recent plugins like and redirect users once they liked the page?
Eric.
If you are using a XFBML like button then you can use the JavaScript SDK to detect likes by subcribing to the edge.create event using FB.Event.subscribe
FB.Event.subscribe('edge.create',
function(response) {
// Do redirect here
}
);
For more information on the Facebook JavaScript SDK please go here:
http://developers.facebook.com/docs/reference/javascript/

How to catch action from Facebook 'Like' button

Is there a way to catch event of clicking Facebook like button? I don't want to integrate my app with Facebook, just need to count clicks of 'Like'. Tried :
$('.fb_iframe_widget').click(function(){
alert("clicked");
});
but without any luck. If there is no way of doing this will I be able to count likes of particular pages when synced with FB API ?
You must use the xfbml like button rather than the iframe button. After you switch that, do the following:
FB.Event.subscribe('edge.create', function(response) {
// user clicked like button!
});
The facebook event "edge.create" is called when a like button is clicked. I have no idea why it is named that, but that will do what you are looking for.
If that doesn't work, then I think you'd be out of luck, as you can't do anything else because of same origin policy.