Reputation: 89
I am using a facebook registration plugin to register users if they have a facebook account or using the default registration form if they don't have a fb account.
I have created the default registration form in yii framework storing data using model into database.
I have also written code to use facebook registration plugin using iframe.
The problem is that how to save the data in database filled in fb registration plugin form and what to mention in redirect-uri ?
Upvotes: 0
Views: 918
Reputation: 4334
After facebook has authenticated the user, and given permission to your application, you can get the user data using the facebook sdk (either php or js) by calling the api method "/me".
example using the php sdk:
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me');
//Now using the the facebook data we create 'our' user
$model = new User;
$model->username = $user_profile['fullname'];
//and so on..
$model->save();
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
more details in the oficial php sdk repo
The return URL must point to your application's page, the one you configured when you created the application on facebook
Upvotes: 2