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.
Related
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.
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
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).
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/
I want to send Facebook friend invitations to some of our friends list without using FBML tags (<fb:request ....)
I am writing code in ASP.NET using fbServices.
How can I send friend requests without using FMBL tags?
Friend requests cannot be done through the Facebook API. The FBML fb:request-form tag is the only way to do this.
I spent a great deal of time looking, and finally came accross a very simple solution.
Using the Facebook Javascript API you can do a friend request with:
<script>
FB.ui(
{
method: 'friends.add',
id: fbid // assuming you set this variable previously...
},
function(param){
console.log(param);
// If they cancel params will show:
// {action:false, ...}
// and if they send the friend request it'll have:
// {action:true, ...}
// and if they closed the pop-up window then:
// param is undefined
}
);
</script>
The callback script can then simply performs an ajax call to your server where
you save info about the action, if needed.
You can test this by using the javascript console app on Facebook:
http://developers.facebook.com/tools/console
Paste in the script above, including the tags, or click the "Examples"
button on the bottom of the text area and find the "fb.ui — friends.add" example.
fb:request-form is now obsolete and will be deprecated eventually. The new way, announced on 27 January 2011, is the Requests Dialog.
Facebook does not allow you to programatically send friend requests.
I suggest taking a look at their API
Okay. Years later, things has changed:
https://developers.facebook.com/docs/reference/dialogs/
Dialogs provide a simple, consistent interface to provide social
functionality to your users. Dialogs do not require any additional
permissions because they require user interaction. Dialogs can be used
by your application in every context: within a Canvas Page, in a Page
Tab, in a website or mobile web app, and within native iOS and native
Android applications.
There are currently 7 Dialogs available for you to use:
- The Feed Dialog allows a user to post a story to their Timeline and to their friends' News Feeds
- The OAuth Dialog allows a user to authorize an application as part of an authentication flow.
- The Add Page Tab Dialog allows a user to add an application to a Facebook Page which they administer.
- The Friends Dialog allows a user to send a friend request to another user.
- The Pay Dialog allows a user to make a purchase using Facebook Credits.
- The Requests Dialog allows a user to send a request to one or more of their friends
- The Send Dialog allows a user to send a Facebook Message to one or more of their friends.
See also: https://developers.facebook.com/docs/requests/
You can send requests to friends without using FBML as follows
`FB.ui({
method: 'apprequests',
message: 'This is my applicaiton',
title: 'Application Request without FBML',
filters: 'all'
},
// Callback function returning the list of requestObj Ids
function(response){
}
);`
For more info you could refer
Wiki Page for apprequest graph API