getting notification when someone comments using comments plugin - facebook

So I have an iFrame app on a fan page, which includes the comments plugin. Is there a way I/any admin can receive a notification or email every time someone adds a comment?

You can subscribe to comment.create event and send the notification to admin in any way you prefer, once comment is created. Facebook itself doesn't provide such functionality.
This may looks like this (I assume Facebook JavaScript SDK is already loaded on page before doing this, read about it in documentation on Loading, anyway if you're using Social Comments Plugin it should be loaded already):
<script type="text/javascript">
FB.subscribe('comment.create', function(response){
// Here you need to do a call to some service/script/application
// to notify your administrator about new comment.
// I'll use jQuery ajax to call server-side script to illustrate the flow
$.post('//hostnamne/path/to/script', {
"action": "comment created",
"url_of_page_comment_leaved_on": response.href,
"id_of_comment_object": response.commentID
});
});
</script>
In your script located at http(s?)://hostnamne/path/to/script you can send a notification to admin, how to do it may vary on way you want it for example if you want to send an email you can use something like this php sample (aging this is just a flow sample, not real code you should use):
<?
$admin_email = 'root#localhost';
$commentID = $_REQUEST['id_of_comment_object'];
$page_href = $_REQUEST['url_of_page_comment_leaved_on'];
$message = "comment #{$commentID} was leaved on page {$page_href}";
mail($admin_email, "You have a new comment", $message);
?>
If you need to track the deletion of comments too you can use comment.remove event with similar flow...

Related

LinkedIn Ads conversion tracking Sleeknote forms

Im an intern and has been granted the privilige of setting up connversion tracking, so we can track who that has been signing up to our newsletter after they clicked one of our LinkedIn Ads. But i have some trouble making it work.
So far, we have integrated the LinkedIn insight Tag in the footer of the website, so it will be able to track conversions. The Insight tag source status is Active, so that’s all good.
Furthermore, we have set up the conversions we want to track and used the ‘Event-Specific’ method. To track when someone is submitting a form, in this case our newsletter sign-up form, I’ve pasted the code below to the header of our website. Then it should be triggered when someone submits the form. The var id is the campaign id for the newsletter signup in Sleeknote. "Your code here" == LinkedIn event-specific snippet
<script type='text/javascript'>
document.addEventListener('sleekNote', function (e) {
var id = 'INSERT CAMPAIGN ID HERE';
if (e.data.type == 'submit' && e.data.campaignId == id)
{
"Your code here"
}
}, false);
</script>
I used this documentation: https://help.sleeknote.com/hc/en-us/articles/7005018805661-What-is-EventEmitter-
Does anyone have a suggestion of how i can make it work?
Thanks in advance!
I've tried reaching out to Sleeknote and LinkedIn

Display something for people who like or not like our facebook page

I search a solution for the problem highlighted in this question.
Unfortunately, the accepted solution (which dates back to 21/11/2012) doesn't work anymore, as you can this in this demo.
Does someone know why?
Body
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : '179378788777832',
status : true,
cookie : true,
xfbml : true
});
</script>
<div id="login">
You are not logged in to FB, Please click here to login.
</div>
<div id="container_notlike">
YOU DONT LIKE
</div>
<div id="container_like">
YOU LIKE
</div>
JS
var hideLogin = function(){
$("#login").hide();
}
var showLogin = function(){
$("#login").show();
}
var doLogin = function(){
FB.login(function(response) {
if (response.session) {
hideLogin();
checkLike(response.session.uid)
} else {
// user is not logged in
}
});
}
var checkLike = function(user_id){
var page_id = "40796308305"; //coca cola
var fql_query = "SELECT uid FROM page_fan WHERE page_id = "+page_id+"and uid="+user_id;
var the_query = FB.Data.query(fql_query);
the_query.wait(function(rows) {
if (rows.length == 1 && rows[0].uid == user_id) {
$("#container_like").show();
//here you could also do some ajax and get the content for a "liker" instead of simply showing a hidden div in the page.
} else {
$("#container_notlike").show();
//and here you could get the content for a non liker in ajax...
}
});
}
$(document).ready(function(){
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
hideLogin();
checkLike(response.authResponse.userID)
} else {
showLogin();
}
});
$("#login a").click(doLogin);
});
CSS
body {
width:520px;
margin:0; padding:0; border:0;
font-family: verdana;
background:url(repeat.png) repeat;
margin-bottom:10px;
}
p, h1 {width:450px; margin-left:50px; color:#FFF;}
p {font-size:11px;}
#container_notlike, #container_like, #login {
display:none
}
I search solution for hours but I didn't find anything what works.
Thank you for help.
Like Gating is not allowed anymore, that´s why it is not possible. The only reliable way to get that information is by authorizing a user with the user_likes permission and using /me/likes/[page-id]. But you will not get that permission approved for like gating in the Login Review.
People need to like something because they really want to, not because they get something for it:
Only incentivize a person to log into your app, enter a promotion on your app’s Page, or check-in at a place. Don’t incentivize other actions
Source: https://developers.facebook.com/policy/
Btw, you can also subscribe to the edge.create event to find out if a user just clicked your like button, but you can´t find out if the user liked it before: https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/
The problem on that code is that FQL is deprecated .
You can't do what you want to, and thats why changes are necessary .
Your code would work if your app is old, created before changes that turns like gating not allowed, but anyway, you cannot use that for show content. You can use that kind of implementation for creating an interactive experience, where you can for example changing the content, saying "Thanks for liking".. Or "Connect with us, liking our page.." ..
You can also think about interfaces, where you show up the page plugin, and just after user likes, you say Thank you ... and hide the page plugin ... But user must always be able to close without liking .
For checking if user likes a page, you need use :
FB.api get on '/me/likes', and with the response ...
if (response.data[likes].name == "Coca-Cola")
or... better
if (response.data[likes].id == "40796308305") {
}
I repeat, One thing has nothing to do with another ..
You can check if user likes a page, but you cannot restrict content, based on this kind of resource .
There are other ways to check it, for exaple :
Get api call to userid/likes/pageid returns page info if user likes the page, and returns nothing if user does not like the page .
You will waste time trying do that for controlling content consumption .
Your app must be aprooved for asking user_likes permission, and its better you think about creating another experience for users, instead of submitting something like that .
I also think that content with good open graph for sharing, commenting and optional liking is very much more efetive, because i noticed that many people used to like and dislike the page after getting the content .
If you just... Prompt a FB.UI for sharing after 1 minute, for example, you will have much more results .. Aways positioning the page plugin in strategic places, people will naturally like your page ..
Than you can say change the page plugin element :
Thank you for liking, please share with your friends ....
Who would also like ...
Or use a callback for triggering the share dialog ..
OLD SCHOOL API CALL
The method FB.Event.subscribe() allowed apps to subscribe to a range of events, and define callback functions for when they fire, is deprecated .
Also FQL Query is deprecated .
For checking if user likes a page, you need user.likes permission, so you can try :
FB.api get on '/me/likes', and with the response ...
if (response.data[likes].name == "Coca-Cola")
or... better
if (response.data[likes].id == "40796308305") { }
There are other ways to check it, for exaple :
Get api call to userid/likes/pageid returns page info if user likes the page, and returns nothing if user does not like the page .
You can check if user likes a page using this call, but you cannot restrict content, based on this kind of resource .
2018 UPDATED SOLUTION
But nowadays, in 2018 the best method for is setting Webhooks .
Webhooks are a subscription based system between Facebook and your server. Your app subscribes to receive updates from Facebook via a specified HTTPS endpoint .
This allows your to app to receive notifications whenever there are updates to a chosen set of topics and their fields, so, you can track changes to most sections of the user's profile, such as About, Photos, Posts, Friends, and Likes.
Webhooks update notifications are sent as POST requests to a callback URL that you supply. Notifications can be lightweight, indicating only that a field has been updated, or can include the newly updated value .
webhooks user reference
Full list of user profile fields that you can subscribe to, such as About, Photos, Posts, Friends, and Likes.
webhooks page reference
The easiest way to set up your app to receive Webhooks updates is to use the App Dashboard's, check out Facebook Platform documentation for more info .
Webhooks documentation

How to create a custom poll on facebook via open graph?

I wanto to create on my facebook page (facebook.com/genericco) a custom poll, in it I wanna create funny polls people can vote on (mainly yes or no answers) and I'd like to post on the voter's wall the action (john doe voted yes on Genericco's poll: Do you think chicken-fish should stop smoking for health issues?).
So I could not do that just using graph API and reading my own questions...so I decided to use the open graph! I created an action called vote with the custom property answer as a boolean...
I've also created the object poll with image,question, title, description and the custom property question...
I've also populated with custom data in the aggregations part.
Then i used Putty program to run the code and be able to submit my custom action for approval...
My question now is...How do I use it? How do I put this together to achieve the objectives I've proposed on the top of this question?
can anyone shed a light?
So...I managed to build the customized poll app with Open Graph in facebook. its going well...but its not 100% yet. let me tell you guys why:
1 - So I managed to understand how to creat an action, I called it "Vote", it is connected with the Object type "Poll" I created; The action "Vote" has 2 custom properties: "Answer" wich is a String and "Name" wich is also a String;
2 - Then I created the object "Poll" and I filled it with sample data and stuff and also I created the custom property "Question";
3 - Then I created the aggregation "Enquete Ociosidade" (roughly translating would mean sloth poll) and the data is displays is the action "vote" and in the Caption I used something like this {poll.question}{name} thinks {answer};
Then to make it work I had to send a sample of the action to facebook somehow, I had no idea how to do this so I used Putty and simply pasted the code facebook provides for that; It worked;
Then comes the hard part, how would my front-end app send those info to facebook so I could register the action? Well I'm glad you asked!
I tryed till it worked...YOUR APP MUST HAVE PUBLISHING_ACTIONS PERMISSION THIS IS VERY IMPORTANT!
so...this is the code I got working:
FB.api('/me', function(response) {
//alert(response.name);
FB.api('/me/genericco:votar_poll&enquete=http://www.limonadaweb.com.br/genericco/poll_data.php&resposta='+resposta+'&nome='+response.name+'&access_token='+_token+'' ,'post', function(resp) {
if (!resp || resp.error) {
alert('Error occured '+resp.error.message);
//mostrar caixa de diálogo que algum erro ocorreu;
} else {
alert('Post was successful! Action ID: ' + resp.id);
//fazer algo legal para demonstrar que deu certo o voto;
}
})
});
what I did was...first I make a FB.api call to get the users name, in the callback I make a FB.api call to register the action VERY IMPORTANT TO PASS THE ACCESS_TOKEN TOO...and must be POST.... and that is all there is to it! very cool right? And all that code is inside a function my app calls whenever the user votes and sends a boolean value that I use as the answer to know if the user voted 'yes' or 'no'.
That is all very good and is working fine! Just fine....
My problem now is that now when the action is published in my timeline and newsfeed and stuff it sends the user to this link below...it has absolutely nothing visual in it...it is the poll's data...a bunch of metatags...
i'd like to know if it is possible to send the user to another link when he/she clicks the link of my feed...
http://www.limonadaweb.com.br/genericco/poll_data.php?fb_action_ids=10150744684398313&fb_action_types=genericco%3Avotar_poll&fb_source=other_multiline

Automatic Timeline Action posting

Following Facebook's Guide for the new open graph, I have managed to implement Timeline and "Read Article" Action on our WordPress-based site. But the guide makes you click a button to post the action. It might be silly question, but how do we make it automatically posting once user enters the article? Is that something that's happening AFTER the action has been approved by Facebook?
Does recommendation bar do that? Is that its purpose?
Yes, the Recommendations Bar does this. You could implement something similar in your own code but the Recommendations Bar supports a bunch of things out of the box like sending the activity only once the user scrolls X% of the way down and/or after a specified time interval.
Using this markup the action should be tracked in 5 seconds after the bar has loaded:
<div class="fb-recommendations-bar" data-href="{YOUR URL}" data-read-time="5"></div>
The Recommendation Bar is still in beta and won't work for anyone other than the App Administrators / Developers / Testers.
End-users will only get actions published once Facebook has approved the action. This usually takes a day or two if you provide adequate instructions. You will need to make sure users are able to remove their activity from within your site - this is a requirement for submitting a action:
Please make sure your users can
Turn sharing on/off globally on each page an article appears.
Remove articles they shared within your app on each page an article appears.
Only generate read actions when you're sure someone is interested in reading the article.
For my WordPress site, I used some code like:
setTimeout( function() {
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// publish action to facebook
FB.api( '/me/{$action}', 'post', { article : '{$permalink}' } );
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
} else {
// the user isn't logged in to Facebook.
}
});
}, 2000 );
Use some JavaScript to post the action after the page loads:
window.onload=postCook;

How to Add facebook "Install App Button" on a Fanpage Tab (Based on working example)

For some time now I try to figure out how these guys were able to add "Sign online here" button which is "install App" button on their fan-page tab:
http://www.facebook.com/GuinnessIreland?v=app_165491161181
I've read around the web and couldn't come up with any solid solution. The FBML and FBJS documentation left me with nothing.
So please, if anyone can help me with this.
NOTE: To make multiple tests on the Ajax request that are sent, do not accept the App install. It behaves differently after that.
I had some problems with finding out about it as well. There is no info about this kind of behavior in wiki or anywhere. I got it working after trying some possible solutions and the simplest one is to make user interact with content embedded in fan page tab such as click on something etc. Then you need to post an ajax request with requirelogin parameter to pop up to come out. The simple example would be:
user_ajax = function() {
var ajax = new Ajax();
ajax.responseType = Ajax.RAW;
ajax.requireLogin = true;
ajax.ondone = function(data) {
new Dialog(Dialog.DIALOG_POP).showMessage('Status', data, button_confirm = 'Okay');
}
var url = "http://yourappurl.com/request_handler"
ajax.post(url);
}
And the trigger for it:
Interaction
Then if user is known to be using your application (fan page tab) you can prompt him for additional permission like publish stream or email communication by calling:
Facebook.showPermissionDialog('publish_stream,email');
Hope this solves the problem.