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);
});
Related
My site has the option of registering with and without facebook. When you register with facebook though, extra information is needed. This is fine, as I use fb:registration and specify extra fields.
However, the problem is, when a user comes to the site and hasn't registered, sees the facebook login button and clicks it, the link brings them to facebook to login and the app is registered and bypasses the registration form I have.
I there a way to redirect a non-registered user that is not logged in with facebook to a registration page instead of adding the app?
You can add the registration-url parameter to the login button as documented in the Login + Registration Flows section.
<fb:login-button
registration-url="yoururl" />
This isn't documented so I don't know if it will continue to work but if your using the HTML5 version of the login button then you can use:
<div class="fb-login-button" data-registration-url="yoururl">Login with Facebook</div>
Not 100% sure i understood you but..
Going on the assumption that you only want users who have an active FB browser session and have authorized the use of your application with their account to see your login button/a particular page you could try this right after your FB.init:
FB.getLoginStatus(function(response) {
if(notLoggedIntoYourSite && response.status != 'connected') {
// Redirect user or hide login button
}
})
Ref: http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/
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).
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.
I'm having a problem with the good ol' facebook like button on my site. I've implemented it all, I can click on "like" and it appears on my wall (and on the site the count pops up to say "1"), but the count never updates. If I refresh the page it just shows the "like" button again (no count), and if I log in to facebook with a new account and click on like again, it just says "1" again.
An example page on my site:
http://www.makemeacocktail.com/recipe/6741/
The fql readout (watch the apostrophe escape here, copy and paste dont just click):
https://api.facebook.com/method/fql.query?query=select%20total_count,like_count,comment_count,share_count,click_count%20from%20link_stat%20where%20url='http://www.makemeacocktail.com/recipe/6741/'&format=json
The FB XML that is being used:
<fb:like href="http://www.makemeacocktail.com/recipe/6741/" send="false" layout="button_count" width="50" show_faces="false" font="arial"></fb:like>
Other facebook thoughts etc:
I've got the facebook open graph meta data in the head
The js call to facebook happens as the last thing on my page, after the FBML:
<script src="http://connect.facebook.net/en_US/all.js#appId=187430904631019&xfbml=1"></script>
<script>
FB.init({
appId : '187430904631019',
status : true,
cookie : true,
xfbml : true
});
</script>
I've also got the facebook page like at the bottom of my page:
<div id="fb-root"></div><fb:like-box href="http://www.facebook.com/makemeacocktail" width="292" show_faces="false" stream="false" header="true"></fb:like-box>
Which is where the fb-root is.
My only thought it something about fb-root not being next to the facebook like button earlier up, and a conflict of two facebook like buttons or something? I;m only calling the facebook js once though, right at the bottom.
Any thoughts help etc much appreciated. It is weird because it it going to my wall, but the button on the site isn't listening!
Thanks a lot
Got this from the request your like button sends to facebook:
App ID does not match domain","full":"The app ID specified
within the \"fb:app_id\" meta tag is
not allowed on this domain. You must
setup the Connect Base Domains for
your app to be a prefix of
http:\/\/www.makemeacocktail.com\/recipe\/6741\/
So, you need to change the base domain for your application in the developers application to makemeacocktail.com. If that is not the problem try removing the fb:app_id open graph tag, or use the fb:admins tag instead. Good luck, hope this helps.
I have this Facebook application profile page:
http://www.facebook.com/developers/editapp.php?app_id=122313254494566#!/apps/application.php?id=122313254494566
which is associated with my iframe-based Facebook application, Gem Spinner:
http://apps.facebook.com/gemspinner/
My understanding from reading recent Facebook documentation is that in the last couple months Facebook changed the method by which users can "bookmark" an app ("bookmarking" as I understand it, is the process of adding an icon for the application to the user's list of applications on the left side of the Facebook home page). My understanding is that bookmarking is now supposed to happen automatically the first time the person uses the app.
But that's not happening for my app. When you go there, it just shows you the app page and lets you play the game. There is no confirmation message, like I see with other apps, checking if I want to allow this app to access various information from my Facebook account. And there is no bookmark/icon added to the application list on my home page.
So I'm obviously missing something. I tried to follow the instructions here: http://developers.facebook.com/docs/guides/canvas/, including the part on bookmarks, but again that part makes it sound like it will just happen automatically.
My app has been approved for the Facebook directory (although it is not yet showing up in searches of the directory). And it's not in "sandbox" mode.
Perhaps there are some Facebook API calls I must make to let the user "install" the application. If so, I'd love to know what those are.
Apparently the thing I was missing is that it's necessary to call FB.login() from within your javascript code in order to get facebook to "automatically" bookmark the application for the user. I guess this makes a certain amount of sense, since the user has to be "authenticated" with your app before your app (or Facebook on behalf of your app) can make any changes to the user's account, such as adding a bookmark. Nonetheless, it seems like it could have been the case that it added the bookmark without the authentication, and certainly reading the Facebook documentation one would think that simply visiting the app would create the bookmark, regardless of the authentication.
Anyway, another problem was how to make the authentication happen in a smooth way. It may be that there's a more clever and more functional way to do this using page redirects, but it seems like this new API wants to show a pop-up window for the login UI. If that popup is triggered by a button press (i.e., a button that says/means "click here to authenticate with this application"), you get the popup without the terrible browser popup warning. But if you just call the FB.login() function yourself, you get the terrible warning.
So, to get around this, I had my code trigger the button event, and it worked (at least on Firefox). The code is:
<body>
<div id="fb-root">
</div>
<script src="http://connect.facebook.net/en_US/all.js" type="text/javascript"></script>
<script type="text/javascript">
FB.init({
appId : 'your app id here',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : false // parse XFBML
});
function fblogin() {
FB.getLoginStatus(function(response) {
if (response.session) {
// logged in and connected user, someone you know
} else {
// no user session available, someone you dont know
FB.login(
function(response)
{
if (response.session)
{
// user successfully logged in *or* user was already logged in
// *and* user has now been successfully authenticated for this app
// *and* a bookmark added by Facebook for this app
}
else
{
// user cancelled login
}
} );
}
});
}
</script>
<a id="clickme" href="#" onclick="fblogin();return false;"></a>
... the rest of your page here ...
<script type="text/javascript">
document.getElementById( "clickme" ).onclick();
</script>
</body>
This all seems pretty hackish, but I don't know a better way to make the authentication happen automatically while avoiding the popup warning.
It seems to me that the FB.login() function is confusingly named. It really seems to mean, "If the user is not logged in, present the login UI. But if the user is already logged in, or if the user successfully logs in using the UI, also authenticate the user for this application, including automatically bookmarking this application for the user." So maybe at least loginAndAuthenticate() would be a better name.