Update database on remote server when a facebook comment is made - php

I want to update a no_comments row in a database exactly when a facebook comment on my site is made. I would like to do the same thing for likes as well.
I can imagine setting up a cron job that uses the graph API to periodically retrieve the number of comments and likes and update the database but for a large number of objects that are associated with comments the lag introduced is undesirable.
I am not looking for someone to "code a solution" for me...rather can someone point me in the right direction: is it possible to use AJAX to somehow update the database at the point when a comment is made or a like is done?
I can see how one can use the click event for the like button but it's not fool proof...
All help is appreciated!

Assuming you are using Oauth and have a facebook application then I would consult the facebook API docs for events or triggers. If a method exists it will be in the API docs.
Your description of your "site" is vague so it is hard to understand what your site or how it connects to facebook.
Edit:
I wish people would explain down votes. I can't fix it if I don't know what the issue was.
I followed my own advice and searched for this "facebook run script when like is clicked" on Google and found this: enter link description here This is almost the same question except it deals with "like" buttons rather than comments.
You can generate "events" like I had previously suggested. So further consultation of the FB API may be the most fruitful way of finding out if there are events around "comments" as well as "likes".
Maybe the OP knows this, but there are several APIs (last time I checked) to facebook including Javascript methods that could be used in an Ajax manner. However, without further details of their website implementation there is no way to tell.

Related

How to create a facebook app without much knowledge of PHP/MYSQL?

I'm trying to SUGGEST, or CREATE an app, and I don't have any knowledge of facebook app creation... I've looked up on tutorials, but facebook's API might change or has changed by the date of those tutorials...
So I thought I'll ask on here, after searching for a facebook developer's support, I was redirected to here.
My question: What is the best way to create a basic app, as per my requirements (below)..?
My Suggestion/Requirements: I wrote this tutorial on superuser, which lets you display your current playing track as an updated div on your html based website. I'm trying to create a facebook app that posts these track info updates to the right side of the facebook home panel (above the chat column). Like Spotify! Or SoundCloud...
My Problem: I don't know where to start? I don't have much knowledge of scripting and according to me, it should be quite simple in PHP/MYSQL/Javascript/ ... but don't know how facebook would handle the html file from where the <div> data could be collected. I think jquery would solve that, but this can also be done via PHP/MYSQL.
It should be simple, so I'm also suggesting this as an idea for anyone willing to create this app on facebook? And if you create it, please do keep it open source project or a tutorial for it, so that if at any time you close the app, it can still be replicated. I cannot create it but am willing to, but don't know how to...
I'm asking this here because facebook doesn't appear to have a forum based posts for this apart from the developers group. I've joined the facebook developers group, but haven't yet been allowed to post anything, as the join request is pending.
That's mostly all. Thanks for any help.
Start with registering your application on Facebook .It will give you some token and keys.
Now you can follow any tutorial online to create application on fb.

How to update facebook page?

I am a PHP developer who was asked by a client to update their Facebook business page with changing statistics. Not by posting the information as status updates at an interval, but to update the Facebook page description like AJAX would update a page view counter. Is this possible? Can you point me in the right direction of how to implement this?
You're going to need to authenticate your application (this is also good reading here) and ask for extended_permissions, specifically the manage_pages permission.
This allows your application to login as a page.
Then you can modify certain parts of the page attributes.
There is a nice class available on phpclasses.org to aid in logging in with facebook, though their own PHP SDK is really nice when you get used to it.
Good luck!

How do you delete a Mention Tag using the FB API?

FB, having updated their API to disallow generic shares (Oct 2012), now require us to utilise built-in actions. Moving on from there, we can use Mention Tagging (https://developers.facebook.com/docs/opengraph/mention_tagging/) to allow messages and mentions be created - this is all fine.
However, on the same page above they say "You must also describe step-by-step how users can add/remove tags in your app." - but they neglect describing what call must be made to the API to do so.
Has anyone else done this successfully?
Say I have a user who's mentioned 5 people in an action post. Then say one of them would like to be untagged. I provide them a link to allow them to untag themselves, but what call should be made to the API.
Has anyone got any experience at this? All help appreciated.
Paul G
Say I have a user who's mentioned 5 people in an action post. Then say one of them would like to be untagged. I provide them a link to allow them to untag themselves
I don’t think you have to offer a link for tag removal to the other users that have been tagged by your user. Standard FB functionality through the facebook.com UI should enable them to do that already.
It does not make much sense to me to offer such links on your own to people that have been tagged by your app’s user, but might not even be using your app themselves. (To ensure that they are legitimately requesting to be un-tagged, you’d have to identify them first – by having them connect to your app. I don’t think that’s how Facebook want it to be.)
To me, the intention of the guidelines is more to ensure that you are building a clearly understandable UI for your app, for the process of the user entering his message. If they start to type #PaulG, and you want to “translate” that into a tag, f.e. by highlighting it in the text edit box like it happens on facebook.com, then it a) has to be absolutely clear to your user, that they are tagging someone this way, and b) you have to give your user a way of removing that tag right there and then (before posting his message), in case he does not want to tag a user, but just have the characters “#PaulG” stand for themselves in his message.

Facebook API. Remove tags, wallposts, messages from a certain user

I'd like to remove as much as possible of my history with a certain facebook user via the Facebook API.
I want to be able to remove photo tags, wallposts, messages that I am tagged in, or associated with the certain user.
Is this possible, and if yes; how?
Blocking the user will go a long way towards removing most connections with the person in quesion. Go to Account->Privacy Settings->Manage Block Lists, or go to the users profile and look for the "Report/Block" link under their friends/family lists.
This FAQ about blocking describes a little about what happens when you block someone. As far as photos goes, it's a little unclear:
Photos: If the blocked person tagged you in any photos before the block, you’ll still be able to see those photos. You might also see photos of the blocked person if they are tagged in another friend’s album, but you won’t be able to click on their name to see their profile.
You do automatically get un-tagged from all their photos when you block someone. I'm guessing wall posts you're tagged in are removed as well, although I only tested with photo tags.
As far as removing their posts to your wall, as Igy pointed out you can't write an app that uses the API to delete posts that it didn't create. So, what I would do is write an app that gets all the posts on your wall and filters them, something like this pseudo-code:
posts = api('/me/feed')
for each post in posts:
if post.from.id == [blocked persons id]:
output post.id
Post ID's from the Graph API are in the format USERID_POSTID, so there are two ID's separated by an underscore. So for each ID in the output, go to https://www.facebook.com/permalink.php?story_fbid=[POSTID]&id=[USERID] and manually delete the post by selecting "Remove post" from the little gear menu on the top right of the post. Use the paging data from your API request, or until and since parameters (which are just UNIX timestamps, or any string accepted by the strtotime function), as described on http://developers.facebook.com/docs/reference/api/ under "Paging", to get all posts going back until the beginning of your wall.
If you are wanting to automate this process to make it available to end users and not just yourself, there are technically several ways you could go about it, although they may or may not violate (Terms of use)[http://www.facebook.com/terms.php]:
[3.2] You will not collect users' content or information, or otherwise access Facebook, using automated means (such as harvesting bots, robots, spiders, or scrapers) without our permission.
I'm sure there are ways of implementing such an app that doesn't violate these terms, for example providing a link to the post so that they can delete it themselves, rather than automatically deleting them.
http://suicidemachine.org/
I'd look into their code.
From their FAQ on if you can make your own:
Theoretically yes! Practically no (or let's say, not yet)! You'd need a Linux WebServer (apache2) with perl and python modules (php should be installed as well). Further, you'll need VNC-server and Java packages by Sun to launch selenium-remote applets. If you feel like contributing and can convince us with decent programming skills, please get in contact with us via email. We don't make the source code publicly available, since Facebook, Twitter, Myspace and LinkedIn would figure out how the suicidemachine is working in detail! So, please do not contact us, if you work for one of these companies!
I'm not even sure (personally) why you'd want to do this, surely you'd either want to block the other user or just remove them as a friend, but to answer your question:
It's not possible to delete most types of content via the API unless the App ID you're using was the original creator of that content (e.g an app for posting to your wall can delete the posts it made, but not posts made by other apps or on the Facebook.com interface)
Check the documentation at http://developers.facebook.com/docs/reference/api/ - you can definitely remove likes and comments of photos and wall posts - there may be other ways to do this (e.g retroactively changing your RSVP status to an event both users went to)

Question regarding publishing to a user's facebook feed

Currently I am building a small application that allows a user to sign in to their Facebook account and update their status from within the application.
However, the Facebook API does not seem well documented and I am having trouble locating sources of information that are relevant to the specific project that I am building.
Does anyone know of any articles that might be of use to me?
Thank you.
The documentation is there, scattered around and difficult to find, but there. These two links may help if you are looking to post to someone's wall. FB.ui is sort of a multi-purpose call that will present different dialogs, prompting the user for action. It's far easier to implement than it is find.
http://developers.facebook.com/docs/reference/javascript/
http://developers.facebook.com/docs/reference/javascript/fb.ui/

Categories