I'm interested in using Facebook as a way to validate that someone is my friend on an external site, and based on that, show them special content.
Inside Facebook, consider this scenario:
I post photos and give permission to friends only
Someone tries to view my photos by URL
If that person is my friend, Facebook displays the photos.
I want to mimic this behavior on my own personal website:
User follows a link to "private" content
My site (either by server-side, JS, Ajax, iframe, whatever) asks Facebook if the person is logged into Facebook in their browser.
If not, user is presented with a Facebook popup to log in.
When the user is logged in, my site asks Facebook if they are my friend (ID coded into the site), and if so, presents them with the content
Is this possible without requiring the user to "authorize" my site or application? My only idea (based on http://wiki.developers.facebook.com/index.php/Authorizing_Applications) is that I could create an application for my site, and then on the external site, load my Facebook application in a hidden iframe (which would in turn load my site in an iframe) to give my site the Facebook user ID and store it in the session.
What is the best way to accomplish this?
Yes, this should be possible. You would have to utilize Facebook Connect. The basic flow would be something like you described above:
User on your site follows a link to
private content. This content is
marked in your database (or otherwise) with the owner's Facebook Id.
Your site uses the Facebook API to
check whether the visitor is logged
in to Facebook. If not, deny
access.
If they are logged in, you can
utilize the friends.areFriends API method
to compare the visitor's Facebook ID
with the content owner's Facebook
ID. If they aren't friends, deny
access, otherwise you can show it.
Facebook Connect is actually fairly easy to implement, despite the terrible docs that are hard to understand. Once you have it up and running, it basically means that any visitor to your site that is logged in to Facebook will provide you with a session key that you can use to query Facebook for information about them.
Related
I have a web page linked to a Facebook application where users can log in by their Facebook account.
I have also a Facebook page for my application where anybody can post.
What I'd like to achieve is the following:
- An ordinary user logs in to my web page using her Facebook account,
- She adds an information to my web page (for example a book name),
- That information is instantly posted to my application Facebook page under page's name (for example "this book is read by someone").
I don't want it to be posted by the user, I don't want it to be posted by myself (admin of the page).
I don't want to mention about the user, it will be anonymous information.
But I couldn't find a way to do it either as JS or PHP.
Any suggestion is welcome.
Many thanks.
You will need to get a page access token. https://developers.facebook.com/docs/facebook-login/access-tokens/
Get it, store it somewhere on your server – and then use it when making the API call to post what the user entered.
The facebook "wave" has finally hit me and I see that it's now time to integrate the wonders of the Facebook API into my site. I'm a little worried about implementing a "Login with Facebook" button because my site stores information about each user, and I'm not sure whether or not the facebook login system will also store said information. Any user who registers to my site has the ability to "like" certain pages that were found while browsing the site, and the categories of each page the user likes is stored and linked to his username.
If the user were to "login with facebook" however, and thus skip my registration page, would the information about categories still be saved?
Even looking at StackOverflow.com, I notice that all of my profile information etc. is being saved, but where? I used the login with facebook button so where exactly is my profile information being saved?
When you login with Facebook your site gets a Facebook ID and some other information (depending on what you ask for, but normally first name, last name, email address). You can then use the Facebook ID or email address to link it to an existing account in your system. If you can't find it, automatically create a new account with the details provided from Facebook.
You can use the Registration Social Plugin that facebook offer in order to get the data you need from the user while they register to your site using their facebook profile.
Also, as #JonGrant wrote, you can just use the api to get the needed information from facebook, just take into consideration that the more permissions you ask for, the less users will authorize your app.
Edit: Plugin now out of date, please refer to Facebook Login.
This was plugin removed as of API version 2.0. It will stop working
on July 30, 2015. Apps using this plugin should migrate to Facebook Login.
Source: facebook docs
I have a web app that is connected to facebook graph, and thus have a corresponding facebook app. I'm looking for a means of communicating with the users of my app through their facebook feed.
So far I've asked the users to like the facebook application profile page for my app, so that when I post news on that wall, the users get it. This causes some confusion since the application profile page is a bit of a peripheral component in the webapp-facebook relationship.
Ideally I would be able to post on facebook either as the app, so that I reach all the registered users, or as the app url (www.myapp.url) so that users who like that url will get the posts. Alternatively somehow link the application profile page and the url/app, so that likers of the url or users of the app get the profile page posts.
Note that I'm not looking to post to users walls (just their feeds) and I'd prefer to post manually, using facebooks interface for posting.
The only ways you can publish into a user's news feed is to use a Facebook Page or a Facebook Open Graph Object. So, you did right by asking users to like your Facebook Application Page. If you've also got a webpage that people like, you can turn that webpage into an Open Graph object by adding an fb:app_id or fb:admins meta tag to the head of the page. Doing this grants you access to publish to your fans' news feeds, and you get access to a Facebook page-like interface (for administration purposes only). You can publish to the user's feed using this feed publisher (just like you would do if your Graph object were any other Facebook Page).
To get to the admin page you just have to make sure your Facebook User ID is in the fb:admins meta tag. Once it is, visit a like button social widget for that object, and you'll get the a link that lets you go to the admin page for the object.
I hope that's clear. You should probably give the Open Graph Protocol Documentation a good read.
I'd like to know if there is a possibility to check (using Graph API or any other way) whether given user likes / shares a specific link. Probably I'll have this user's facebook ID or facebook login, but my site is non-Facebook application. Actually it's Dot Net Nuke portal (target: .NET with MS SQL Server) with part of it being avaliable as Facebook app, but certainly not greater part of it, so the solution should be out of Facebook Connect, although it's not a showstopper if it's necessary.
We'll be giving points to users who share/like most of links that we serve in our portal and such possibility would be a great help to make a ranking.
Another option we consider is making some kind of "wrapper" or proxy for FB like / share buttons which will at first save some data in our database (probably - this user clicked on like for this link) and then go on with standard FB like / share route. Did anybody of You tried such solution?
If You have any other suggestion on the subject, please, post them, we'll be really thankful.
It is possible to know if a user has LIKED a site or not. You can get all user's likes with Graph API (you need user_likes permission). Take a look at the docs: http://developers.facebook.com/docs/reference/api/user/
I'm not sure if you can know if he has shared your site, but you could try by parsing his wall with the read_stream permission and then look for your site name/URL post by post.
For just general liking of items on your site, you can use a Facebook Social Plugin. However, you won't be able to associate (or really even access) user activity with users on your site without integrating Facebook Connect and creating a Facebook application for your site. At that point you can design with greater control all the possible user activity and interleave with your facebook calls other calls that affect users' accounts on your site.
i've built a survey and at the end i want the users to share their result on their facebook wall but i'm finding it hard to find any examples or reference.
something like;
<div>
[ image/graphic ]
"I've just completed survey XXX and got 90%"
<a>post on my wall</a>
</div>
any help appreciated - even if its just terminology i can look up!
Start here. Basically, you're creating a website which you want to integrate into Facebook. To do so, your users will need to "login to Facebook" from your site (unless they're already logged in, such as in another browser tab) and allow your site to perform certain actions on Facebook on their behalf.
The Single Sign-On part is where you will initialize your website as a Facebook application (you'll need to create the application on Facebook first) and provide a login button for your users.
Your login button can be set up to ask the user for specific permissions to act on their behalf with Facebook. I think the one you want is publish-stream but I'm only barely familiar with it, play around with the functionality and see what works best for you. Your users will be presented with a pop-up div stating that your website (or application) is requesting these specific permissions and they have the option to allow or deny. An example can be seen here.
Once you have the user's permission, you make use of the cookie (demonstrated using PHP back on the Single Sign-On link) to gain access to information by use of the Graph API, the JavaScript SDK, Social Plugins, etc.
you should use the facebook api.
Get the "publish_stream" right of a user and use the "api" method of the connection object (with parameters like : '/userid/feed', 'post', array of informations about the post).
I can't find the right code and the official document is not always up-to-date.
OR
Just add a facebook "share" button on your page that uses "meta" markups. You should find examples on about 80% of websites.