fb.event.subscribe and facebook comment box - facebook

Context:
I have a facebook app that is using the facebook comments box.
In this app a user can create an item for sale.
The item for sale is available at facebook_url_for_the_app/item/itemnumber.
When the user that created the item for sale (or any other user) visualizes the page for the created item, the facebook comments box is available.
Desired function:
Currently, if any user writes a comment the user that created it will only know about it if he visits the page.
My Idea to solve the problem:
I have looked into FB.Event.subscribe('comments.create') but there isn't a field to identify a user other than the admin of the application.
Question:
How can I tell my app to create a subscribe to any comments created at the item's page, facebook_url_for_the_app/item/itemnumber.

Joka,
If you subscribe to comment.create event
<script>
FB.Event.subscribe('comment.create', function(resp) {
Log.info('Comment was added', resp);
// add code here to id the user e.g FB.api('/me', function(response) {})
});
</script>
You can then add code to do something with the uid returned by the FB.api call

Joka: I guess this link will help you out in some way. Here u can subscribe for the event and use it accordingly to notify the user.
click here to view the page

You may want to also make them a moderator of the comment box by adding the metatag
<meta property="fb:admins" content="{THEIR_FACEBOOK_USER_ID}"/>
to the head.

Related

How do you create a mobile friendly Like Gate for a Page on Facebook?

I've put a Like Gate on a few of my Facebook Pages and I'm getting a lot of complaints saying that people can't access the content via their mobile device since the mobile version of the facebook website, and the facebook apps for ios/android, don't support tabs on Facebook.
I see there are services out there (I'm not sure how legit they are) that offer a way to create a mobile like gate for your page tab, but I can't find any documentation on how they do it. These services are not suitable for me, because the content on my tab is custom and dynamic.
So, how can I create a interstitial page for a mobile page that requires the visitor to have liked my Page on Facebook before they can proceed? This has to work for new users, as well as existing users who re-visit the tab and without requiring an install to an application.
Thanks!
One approach you can take for a mobile site is to check that the user has liked the page in question via the JS SDK.
If you have a logged-in user to your application, you can Subscribe to the authResponseChange FB event within your JS SDK initialization, or call a function directly to make an API request to verify if the user is a fan of your page.
In your initialization:
FB.init({appId: YOUR_FB_APP_ID_HERE });
window.fbAsyncInit = function() {
// React to a user clicking an on-page Like button:
FB.Event.subscribe("edge.create", verifyUserLikesPage);
}
You can verify that the user likes the appropriate page in the like handler:
function verifyUserLikesPage() {
FB.api("/me/likes/"+FBID_OF_PAGE_TO_ENSURE_THEY_LIKE, function(apiResponse){
if (apiResponse.data && apiResponse.data.length > 0)
// User likes the page. Enabled them to proceed
else
// User does not like the page. Require they click Like.
}
}
More information on the edge.create subscribe via JS available here: https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/

Subscribe plugin not working

So I have a website where I want to put the subscribe button, here is the code
<!--FB SUBSCRIBE!-->
<div class="fb-subscribe" data-href="http://www.facebook.com/Entendu.info" data-layout="box_count" data-show-faces="true" data-font="arial" data-width="50"></div>
But when I visit the webpage (www.entendu.info/moderate) On the right where the susbscribe button is suppposed to shoe I got : error and when I click on it :
The href parameter must reference a valid Facebook user profile, but
"http://www.facebook.com/Entendu.info" is not a valid Facebook user
profile.
The link of the error
But the problem is that my url is totally valid !
https://www.facebook.com/Entendu.info
Thanks for your help
Well the answer is in the error itself -
The href parameter must reference a valid Facebook user profile, but "http://www.facebook.com/Entendu.info" is not a valid Facebook user profile.
you have to use a valid user profile and not the URL of a page.
One can not subscribe to a page in the same way that one can not like a person.
You should use a Like button or Like box in your app if you want to add fans to the page.
There is a different facebook embed code for PAGES and USERS
To subscribe to a Fan PAGE (usually organizations like cocacola, nike, I used it for participateHW)
http://developers.facebook.com/docs/reference/plugins/like-box/
To subscribe to a USER
http://developers.facebook.com/docs/reference/plugins/subscribe/
all the other social plugins are here (just read the description carefully):
http://developers.facebook.com/docs/plugins/

How to auto like facebook page from other site?

On the facebook page,we can click the like button to like the page.
How can we use any api or plugin to realize from other site?
You can not automatically like an object for a user nor can you present like via the APIs. This prevents anyone "secretly" having users like pages / objects.
The solution is to embed a like button to your page and give users a clear reason to use it [sell the benefit of liking your page]. You can run a separate version for individual pages, objects or just an aggregate button for all of your site via the data-href element.
http://developers.facebook.com/docs/reference/plugins/like/
You can check if a user has liked your page using:
FB.api('/me/likes', function(response) {
console.log(response);
});
Loop through the response and look for your page ID.
The open-graph api has now been updated to support creating (and deleting) likes.
See here:
https://developers.facebook.com/docs/opengraph/actions/builtin/likes/

Facebook, who liked our fan page?

I have a Facebook like button on the top of my page and on every product page. How I can find out, where and who clicked the like button (on which product, or on the top of the page?).
You can't because it's restriction of their privacy policy
I've never done anything like that myself, but it looks like you can use Javascript to fire off an event when a given button is clicked -- so you would assign each button on each page a unique identifier and send that back to the server on click. Relevant bits:
After you have obtained the application id you first of all have to add Facebook’s namespace to your html element on the website you wish to add the “Like” button to:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
Then, on the actual page, you include:
window.fbAsyncInit = function() {
FB.init({appId: 'YOUR_FACEBOOK_APP_ID', status: true, cookie: true, xfbml: true});
FB.Event.subscribe('edge.create', function(href, widget) {
// Do something, e.g. track the click on the "Like" button here
alert('You just liked '+href);
});
};
The actual post has a bit more detail.
EDIT: As others have mentioned, this only covers which button is clicked, and not who has clicked it. In addition to being technically impossible and in violation of Facebook's privacy policy, tracking individual Facebook users on your site without their explicit permission is an unethical invasion of their privacy. Respect your users.
You cannot know your users' Facebook account, it goes against Facebook's privacy policy.
As for where on the page, use Javascript.
If a user has connected to the application the xfbml like button is configured to, then yes you can collect the information the user has shared with your application. You can not share the analytical type data though. For your use only.
As per http://developers.facebook.com/policy/ art. II sec. 2,3
** Storing and Using Data You Receive From Us**
You will only request the data you need to operate your application.
You may cache data you receive through use of the Facebook API in
order to improve your application’s user experience, but you should
try to keep the data up to date. This permission does not give you any
rights to such data.
But in art. I sec. 7
Special provisions for apps on Pages:
b. When a user visits your Page, if they have not given explicit
permission by authorizing your Facebook app or directly providing
information to your Page, you may only use information obtained
from us and the user's interaction with your Page in connection with
that Page. For example, although you may use aggregate analytics for
your individual Page, you must not combine information from any other
sources to customize the user's experience on your Page and may not
use any information about the user's interaction with your Page in
any other context (such as analytics or customization across other
Pages or websites).
Step 1
Create a Facebook Page, such as http://www.facebook.com/pages/SomethingFacebookUsersLike/
Step 2
Create a custom Facebook Like button configured for the above URL. Place the Like button on your Web page.
Step 3
Create an event handler for when a Facebook user clicks the like button...
FB.Event.subscribe("edge.create", function(targetUrl) {
// When the Facebook Like Button is clicked (Likejacked), kick off
// a request to the server immediately to see who just now "liked" the page.
// That person who clicked the like button is probably the same person.
dojo.xhrGet({
url : server_url + fb_page_id,
handleAs : "json",
load : function(response, ioArgs) {
// response should have the facebook user data
}
});
});
Step 4
Server-side process makes a request for the fan page of the Facebook Page...
https://www.facebook.com/browse/page_fans/?page_id=[insert_facebook_page_id]
Replace the page ID for the Facebook Page in the above URL. On that page, the top most Facebook user listed, which will include a link to their profile, is the person who most recently clicked the Like button. Visit users profile and screen scape whatever information is sought after. This information would include at least their "real name" and Facebook ID.
Longer technical explanation can be found here:
I Know Your Name, and Probably a Whole Lot More (Deanonymization via Likejacking, Followjacking, etc.)
http://blog.whitehatsec.com/i-know-your-name-and-probably-a-whole-lot-more-deanonymization-via-likejacking-followjacking-etc/

Adding custom actions to facebook comment plugin

I am currently using the normal facebook comments plugin as such:
<p class="fb-comments"></p>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js#appId=API_ID&xfbml=1"></script>
<fb:comments href="URL_OF_PAGE" num_posts="10" style="max-width:480px" width="300"></fb:comments>
I have a custom login section. but I want to be able to see who posts a comment on the website if they are logged in.
In other words this is exactly what I want to accomplish.
if the user is logged in, and they post a comment, I want to be able to store the ID (or username, email, etc) of the user thats logged in - into my DB.
if they are not logged in then i dont care to track it.
any one have any thoughts?
Subscribe to the comment.create method in javascript and then the check values in the response variable.
FB.Event.subscribe('comment.create', function(response) {
alert(JSON.stringify(response);
});