How to programmatically "press" a 'Like' button through a Facebook Application? - php

I'm developing this Facebook Application and I was wondering if it's possible (and how) to programmatically, through the Facebook PHP Graph API, press some 'Like' button on some page?
Of course, this is optional on my application... I'm still not ready to really explain what application I'm doing, but it would be interesting to code such a feature.
Is it possible somehow?

By your description it sounds like you're trying to get a user to like something without the users knowingly clicking a like-button. This sort of interaction is not condoned by Facebook, I think. There are various black-hatty ways to accomplish this though, one fairly elaborate one is descriped here: http://www.liquidrhymes.com/2010/08/25/smoking-hot-bartender-is-some-smoking-hot-facebook-spam/
UPDATE Sorry, I might be wrong. If you get stream_publish extended permissions from the user, you might be able to like posts on their behalf by doing a POST to /POST_ID/likes. See Publishing to Facebook in http://developers.facebook.com/docs/api

You cannot do this. Facebok wont let you do a POST to /POST_ID/likes, you can only do a get request to retrieve their likes. What you are trying to do is a violation of facebook's TOS. I would suggest just adding a like button and "forcing" them to like before they continue with your application. However, in my opinion even that is kind of silly because they can instantly go unlike it after they have used your application.

i was looking for the same thing, but not to force a user into liking something, but actually for their own protection.
here is where i come from: on a web site (maybe on multiple pages) there is an "I Like" button, implemented as described by facebook.
each time a user goes to that page, the browser will make a request to facebook, throught the iframe that contains the button, providing all the info that we are used to from a web server log file.
if the user has in the past logged in facebook and not cleared the cache. the request will also contain the cookie indentifying the facebook user.
so even more then analytics, facebook know all about the user activity on those pages.
so i wanted the user to only give this info when they decide to.
my solution was to have a button (as graphic only) on the page. when the user clicks it a new frame should open and only there the facebook code should be executed.
obviously on the new frame i could not put the normal "i like" code, since that would require a 2nd click for the user. at this point i would need the "programmatically clicking of the i like button".
it is not an opengraph solution, but it works: the frame just does a redirect to
http://www.facebook.com/share.php?u=URL

Related

Invite friends to facebook app (not a game) preferably using PHP

I'm wondering if it is possible to allow a user to invite friends to join my app, even though it is registered as a fitness app and not a game through facebook. Does this even matter?
I'd like to use the facebook requests dialog, but I am being tripped up by the wording in the info section of this page: http://goo.gl/zfx4R where it says that the request dialog is only available to games on facebook.com.
If the requests dialog is not the answer, how should I go about allowing a user to invite their friends? If there is a PHP solution I'd prefer it.
Thanks for the help in advance
As far as I know, there are no features which are restricted to the "type" of app, so game versus app should make no difference.
You can open the FB.ui({method: 'apprequests'}) Facebook Javascript dialog on any web page, the app doesn't need to be in a canvas or page tab. The wording may be confusing, but what is meant is that, when a user does accept an invitation, they will be sent to the app canvas.
This means that you will need to configure your Facebook app to have a namespace (apps.facebook.com/<namespace>) and you will need to handle users coming from invitations at that point. What you do with them afterwards is up to you, you could redirect them to your website if you wish.
You should be aware that the Facebook Requests process is deliberately quite cryptic to avoid gaining information from users who don't want to be involved in your app. Unless you have a specific reason to track invitations, I suggest using the FB.ui({ method: 'feed'}) dialog with a target_id.
Because of this, there isn't and will not be a way in PHP to perform this. You will need to load the JS SDK onto your page and invoke the dialog, then allow the user to make their decision (whether using the 'feed' or 'apprequests' dialog).

Prevent user from like/ share/ add comment to content if he is not directly logged into my website

I am trying to integrate facebook login, like, share, comments in my website.
I successfully done this job "individually" which is obviously easy when the fb documentation is followed.
Now the interesting bit is I was asked to integrate these in such a way that
The user should be able to like/ comment/ share if and only if he is logged into my website with his facebook credentials. Or else a popup should appear asking the user to login before he can do those actions (like/ comment/ share)
The user should not be automatically logged into website even if he has opened facebook in another tab (which I tried to achieve but the user is able to like/ share/ comment even without actually logging into my website which I should prevent).
Please throw some light on how to complete this task. I am using PHP and jQuery.
Thanks for any suggestions.
I haven't ever done anything like this but I assume there is some or other 'widget' on your page that performs the tasks you mention. I also assume that these widgets are provided by, say, facebook.
I would suggest simply not rendering the relevant widget unless your user is signed into your site.
You could render some 'disabled' image that looks like the original that can pop up your login page.

Facebook graph API - liking a Facebook page; can be achieved with correct authorisation?

So I've read up about this everywhere, and the general consensus is that you are unable to like a Facebook page using any kind of API (but you can now like external pages via the graph api, as well as pages that link through to Facebook pages it would seem, e.g. I can create a like on here: http://facebook.com/40796308305).
However, while doing this research, I heard 'rumours' about apps being given the authorisation to like Facebook pages via oAuth or the graph API. Does anyone know this to be true?
Essentially, I have a page where a user must click on the 'like' button of a Facebook page, and then click a button to confirm they have liked it. The back-end then uses then authenticates the user for the app, and checks to see if the like exists on the page. If so, then a new page loads up. If not, they are redirected and asked to ensure they have clicked the like button.
Effectively, I would rather this process be done by telling the user that clicking the button will cause them to 'like' a Facebook page, and do it in one process.
Looking at the graph API, I could create a new 'action' to achieve the same effect, but as I understand it, unless they 'like' the Facebook page, they won't see posts from the page on their timeline.
Does anyone know if any 'rumours' of authenticated apps are true? If not, then what I'm talking about is probably not achievable; but I thought I would ask here first. Just trying to get a final word on the matter.
On a side note; if likes are not possible for pages, is there a way to generate an action, that also subscribes to a pages feed?
Cheers.
Essentially, I have a page where a user must click on the 'like' button of a Facebook page, and then click a button to confirm they have liked it. [...] Effectively, I would rather this process be done by telling the user that clicking the button will cause them to 'like' a Facebook page, and do it in one process.
Then why not just embed the JS SDK, and subscribe to the event of the user clicking the like button …? When you receive the event, then you can reload your page automatically via script.
For the rest of your question: TL;DR, and also not here to discuss “rumours”, sorry.

Posting to User's walls as application using Facebook PHP API

I've been building a web app that uses facebook integration for easier registration/login and notifications for the users. However, for the notifications I want to be able to post to a users facebook wall when something happens on our site.
Really I see two possible problems with doing this. First being that the user will most likely not be logged in to our website when the notification needs to happen. Second I have not found a way to post to the feed using any identity other than the current logged in user.
So to reiterate exactly what I'm trying to do. When some action takes place on my site involving Bob, I want the websites application to post on Bobs wall notifying him of the action as if the application is one of Bobs friends. From some of the things I've seen while researching this, it seems as if facebook might not treat applications like users and I might have to go through a page to accomplish what I want. But really I'm ok with that.
What you need to do is to ask for the offline_access permission. Then you can store their graph id property after they login/authorize to your site's database. Then you just post to that graph id instead of instead of /me. In your case you would then POST a request to the "$user_graph_id/feed" endpoint with whatever parameters you usually have.

FB js invite friend

This is not duplicate, as it may seam from the title. Continue reading.
So what I want is to create JS script, which would automatically send an invitation to a certain user to become a friend.
How do I approach this?
Basically, user will need to copy my JS code to browser URL bar, which will append JS directly to the Facebook session. (meaning that now I can send POST request on behalf of the user)
Of course, users are aware about the final result. (it is sort of blind-dating what I am thinking to make)
Is this theoretically possible?
Edit: I think the best way to implement something like this is to use Facebook Connect to authenticate users on your site and connect the users that way. Once the users have connected on your site, invite them to connect on Facebook too (by using the method below or just linking to their profile). This way, you're controlling the "meet", like you want, but you're also allowing them to connect on Facebook in a legitimate way.
Give this dialog a shot, and just direct the user to:
http://www.facebook.com/dialog/friends/?id=<USER_ID_TO_BE_ADDED>&app_id&<APP_ID>&redirect_uri=<ADDRESS_IN_YOUR_DOMAIN>
Alternatively, you could simply open a popup with that URL using window.open.
From what you suggested in your question though, it doesn't sound like you wish to use the feature like Facebook intended. From the usage notes:
This feature is intended to help users become friends on Facebook with people that they are connected to in real life. You should not use this feature to encourage users to friend other users that they are not connected to in real life. If your app is found to be encouraging this behavior, your usage of this feature may be disabled.

Categories