How to get user e-mail addressess that clicked like button for blog entries or pages with Facebook Open Graph Protocol? - facebook

I have implemented Facebook Open Graph Protocol Full Integration following the http://developers.facebook.com/docs/opengraph/ and http://www.websitedesign411.com/blog/facebook-open-graph-protocol-full-integration-walkthrough.
How can I get user e-mail addressess that clicked the like button for certain blog entries or pages?

You can't. Access to the email address requires prompting the user for extended permissions. You can't get that information through a simple "Like" action. That would be a spammers dream!
http://developers.facebook.com/docs/authentication/

I don't believe you can access a facebook user's email address just because they clicked on your Like button. What you will need to do is get the user to authenticate to your application using facebook connect (usually by clicking on that blue "Connect" button), and in the process you can prompt them to share their email address. Email is an 'extended permission' so you need to ask explicitly for it.
You can implement this authentication bit easily enough with the facebook javascript SDK:
http://developers.facebook.com/docs/reference/javascript/
Once the user has authenticated to your application allowed access to their email you can can fetch their email address via the graph api:
http://developers.facebook.com/docs/reference/api/user/

The easiest way to communicate with folks who like your page is to post interesting messages on your page's wall leading them to your facebook app.
You then get them to authorize your app (with or without extended permissions).
Once authorized, you are able to communicate several ways like:
using livemessage
http://developers.facebook.com/docs/reference/rest/livemessage.send/
create an event and add their user id to it.
BTW, the way to get their user ids is:
1) getting the object id of your page/url using
https ://graph.facebook.com/?id={URL}
2) retrieving the user ids via
https: //graph.facebook.com/{mypageid}/likes

Related

Facebook connect and account remove

I have a website where users can log in with the Facebook oAuth API.
Once the user logs in or registers via Facebook it is stored in my database.
But what I'd like to achieve is, once the user goes to his Facebook application settings page and removes my website app permissions, the used should also be deleted from my database.
Is there any work around to this problem, if this is not possible via the Facebook oAuth API?
You can add Deauthorise Callback URL by Navigating to Settings > Advanced section of your application. Whenever a User Deauthorises your Facebook app, Facebook performs a HTTP POST of signed request to your URL. You may use the field user_id to determine which User has deauthorised your app.
Actually, I would do the following:
Add a date to his last log in to your site.
Have cron job check for old, unused accounts.
Send an email to the user's email address (or Facebook message mail) telling him his account is due to expire soon.
Delete account from database.

pyrocms social module: how to register new user with facebook connect

I'm still new to CI and PyroCMS, and am trying to implement a Facebook login using the Social module in a custom module, which looks like it does everything I want, but I'm clearly missing some basics (I can't find any documentation other than the brief readme)!
So far, I've watched the intro video, and have enabled Facebook successfully. I can connect via FB and see FB listed in /social/linked, but some confusion exists in my mind between the two user groups I've got: admin and user.
The flow I'm trying to construct is:
user arrives at the site and is presented with a survey
user fills in the survey, then is asked to signup (I understand that this is unconventional)
/signup has a facebook connect button, supplied by the social module
user clicks the connect button, and grants permission in facebook's popup window
user should be directed back to /signup, (or maybe redirected to /user/registration) with some details filled in from facebook (eg. email, name)
on submit, user should be added to the users table, as a member of the 'users' group (not admin) with no email activation required
an email is sent, thanks page is displayed
on returning to the site, the user should access their on-site profile using facebook connect.
I've read a bunch of threads on the subject, which have shaped these expectations...
Here's where I'm at:
user arrives, fills in survey, clicks the connect button
user is redirected to the homepage, which displays a standard page (not handled by my module). I need to return to /signup!
Based on this, I've tried setting:
$this->session->set_userdata('redirect_to', '/signup');
in what I believe is the correct controller method (checks to see if the user is logged in before sending the email, then calls template build to display the social buttons), to no avail.
(edit: I now see that the code above relates to the user module, not the social module.. maybe i can transplant some changes...)
My questions:
am i on the right track, or going about this the wrong way?!
am i right in thinking that the FB account will be matched with an existing user if the email addresss exists in the system?
I have only one FB account, which I is authorised for the app, and I'm using to connect with as a user - will this work, or do I need a separate FB account to test as user?
Other notes:
I am testing the site in Chrome, logged in as admin in Firefox.
Facebook is my testcase, I'm looking at supporting FB, LinkedIn, google and Twitter eventually.
Phew! Grateful for any feedback, Tim
I will try to answer some of your questions since i'm currently experimenting with the exact same social module as well and with some addons to it.
am i right in thinking that the FB account will be matched with an
existing user if the email addresss exists in the system?
Yes you are. I checked it myself while troubleshooting the fact that my google (gmail address) could'nt connect while my hotmail (registered email) could. You will have to sync your emails in all your social sites, change the loginsystem (allowing username login for example) or manually connect multiple emails in your account settings..
I have only one FB account, which I is authorised for the app, and I'm using to connect with as a user - will this work, or do I need a separate FB account to test as user?
I suggest u let someone with another FB account test the system (better save then sorry) but in my case I didn't have any troubles using other (normal) accounts to log in.
am i on the right track, or going about this the wrong way?!
This was your first question, but I'll answer this as the last on since I didn't test is myself:
The Facebook App has a setting called "Site URL". This is the url to which will be redirected. Simply change it to the page you wish it to be. You can also try to change the following lines in social/controllers/social.php:
Line 245 (redirect: user is logged in after FB connect)
redirect($this->input->get('success_url') ? $this->input->get('success_url') : 'social/linked');
Line 283 (redirect: user has to fill in some additional fields to complete registration)
redirect('users/register');
Good luck!
The intro video shows off the entire extent of the social module. Frontend registrations, frontend user account linking, and backend account linking for the entire system.
If you wish to integrate custom functionality, custom user flows and other stuff as listed in your question then you will need to do a little custom work with the module. Hack it, extend it, send in some pull requests, whatever, but sadly it cannot do "everything to integrate with everywhere ever" out of the box. :-/

Facebook account to replace registration?

I'm new to all this. This is what i'm after and i'm sure it's possible.
I've got a script where people can register/login in to as members. What i'd like to do is tie it in so that it just uses Facebook users details for the registrations. I've managed to set it up to sign up and and complete a registration using a user's name and email.
What i'd like to do now is automatically log the user in if they're logged in on facebook, is this possible or will they need to click a login button that then takes them to their page? If they need to click a button to login, how do I go about getting the button to take their facebook details and log them in? Also what happens in regards to passwords on my site? Is that stored in the app somehow?
Ideally i'd like to use the popup version of verification rather than the iframe that i've got set up at the moment.
Cheers in advanced for any help for a n00b!
This is in fact possible. Although I for my part was never a fan of such things here's some human-readable (simplified) theory:
Facebook uses a system called OAuth ( http://de.wikipedia.org/wiki/OAuth ). That means, when you want to have the user login onto your site using Facebook you'll of course need to provide a button/facebook-login-frame (see documentation) that says "Log me in with Facebook" or so. You then access Facebooks API (more here: https://developers.facebook.com/ ) and basically tell Facebook who you are ("Hi I'm website XY"). While that happens your user is redirected to Facebooks "permission-landing-page". On that page he needs to confirm whether he is fine with your website accessing certain information (like his name). If he confirms your website receives an access-token granting you access to a subset of his user information which you can then use to personalize his expeirence on your website.
Check out facebooks documentation because they explain exactly your usecase in detail.
(here: https://developers.facebook.com/docs/authentication/ )
PS: You'll of course never have any access to his Facebook login/password. That's kind of the idea behind "delegating" the authentication via OAuth to Facebook. Facebook only provides you with an access token (bound to that particular user who logged in and granted your app/website permissions)

How to contact Facebook Connect users through Facebook's API?

We have users that logged in to our website through Facebook Connect. Now we'd like to contact those users about changes as we indicated in the signup process, but we don't have their email addresses. Only their Facebook ids.
How can we contact them? I understand Facebook removed 3rd parties' ability to send notifications through Facebook's API. We can send them a message through the API either.
So I guess we're left with posting to their wall from a user account of ours. I assume there's a low limit to how often we're allowed to do that and is that even permitted? Or we can make an application request from this designated facebook user account which would show up in their notifications.
Finally, we could manually go to the user's profile page and then click the "send a message" button from our facebook user account... A lot of manual work and I assume this is frowned upon as well. Is there an easy way to find out the profile page URL from a Facebook id?
What's the best approach here where we don't break any rules?
If you are getting stream_publish extended permission in your profile then you can simply post on there wall see this http://developers.facebook.com/docs/reference/rest/stream.publish/
Alternatively this can be a better solution if the user do not granted any extended permission
http://developers.facebook.com/docs/reference/rest/livemessage.send/
you should get "offline_access" from the facebook user requests to post at anytime.

Facebook Connect api in php

HI, I hava a website in php where i have integrated a Facebook Connect API which enabled the Facebook login button.
I login using the button by providing my Facebook credentials. It gets logged in. I can access my profile picture, full name and some other information. But i can't access the user email id i.e. the Facebook user id. I have checked the FBML page here but i didn't get any tag that may give me the user id. I guess that Facebook might not allow me to get the id.
Please help me how to get the Facebook user id from the Facabook Connect API.
Apparently, Facebook uses an numeric increment ID instead of email addresses to uniquely identify each User entity. By Facebook API policies, email addresses are protected to prevent spam and other issues.
In order for an application to get the email addresses of a Facebook User, you will need special permissions from the User. See the API for such permissions.