FB js invite friend - php

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.

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).

How to send a request on facebook?

I read the Facebook dev info on how to make a request (located here) but I don't exactly understand what it does. Here's what I'd like to do. I'm using PHP and javascript.
I want a logged in user to send a request to a specific URL (with parameters attached) to multiple Facebook users (users who are already signed up for my site). Also, I need to be able to get the users that they selected and save them in the database, because only those users will have access to the URL that they're being invited to.
Are there any suggestions on how I can accomplish this?
I'm thinking you are talking about the a url request. From my experience this can be done using a simple JQuery request. You can find an example here and you can also read up on java APIs and how to use the methods(Google it). Hope this helps.
The requests dialog is for invitations to Facebook Canvas applications.
You are most likely thinking about the send dialog: https://developers.facebook.com/docs/reference/dialogs/send/
Add a callback function to FB.ui call that saves the id, this will only work if the user ids are hardcoded in. If the user manually adds them, I doubt you can track it.

Post on a users wall on behalf of my app (not the user)

For several years i have managed to sort things out without posting my own question, but by readings others instead. However, after reading over 200 useless posts, i've decided it's time i get some help.
I'm building a facebook app, and what i wan't to do is extremelly simple to explain. I wan't to notify a certain user about some event in real-time. For example, "the tv show you want to watch starts in an hour". Unfortunately, facebook doesn't allow apps to send private messages to users (which was my first choice). The standard way of publishing on a users wall on HIS BEHALF is not good either, because no notification is triggered. Therefore, my idea is to post on his wall on behalf of the app (or any similar action that will trigger a notification).
I know about app requests, but they are not what i'm looking for either, as you can see, they do not match what i want to do.
Also please note that the event may be particular for each user, so making a post or something for EVERYBODY to see is not an option ("Peter, you have dinner with stacy in an hour").
Firstly, i want to know if posting on the apps behalf (or facebook page, or any other idea) is possible.
If it isn't, i would like to see any other ideas to sort this out. Remember, it's extremelly important to trigger the notification.
Thanks for your time reading this, but i have one last request.
Although what i want to do is pretty simple, there are plenty of similar issues being disscused, which may lead to confusion, so please be SURE that you fully understood what i am asking before answering.
Thanks again
What about opening an event and auto inviting the specific user to the event?
Events invites trigger a notification and the only thing you need is the user's email address which you can easily get.
I am not 100% sure if an app posting on your wall initiates a notification*. Although posting to a users wall on behalf of an app is certainly possible.
You can follow the instructions on this link, under the "App Login" title, and with that retrieve the correct access token you need to make calls as your app.
In order to have the functionality you specified, you'll have to request the offline_access permission from your users - this will allow you to post to your users wall even when he/she is not currently in or using your app. (or even logged into facebook)
*
Usually these posts on behalf of an app are user initiated - ie the user pressed "post to my wall."

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.

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

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

Categories