I register users automatically with my Facebook ID without a pass, so they can only log in if Facebook approves them and recognizes them as Facebook users.
I am using the PHP SDK for Facebook. Also remember that you need a signed request, and the user you are trying to register with must accept your APP before attempting to register (in order to get his / her user ID).
You can get a signed request with the registration plugin OR on the Facebook page tab ...
Here is my code, it is not fully tested, but it works, and will probably help you find a way.
// Registro automático en Drupal con datos de Facebook function fbconex_registro() { global $facebook; global $user; $SR = $facebook->getSignedRequest(); if ($SR['registration']) { $datos = $SR['registration']; $usuario_nuevo['status'] = 1; $usuario_nuevo['mail'] = $datos['email']; $usuario_nuevo['name'] = 'fb-' . $facebook->getUser(); // Comprobar que el usuario no existe $usuario_nuevo = user_save(null, $usuario_nuevo); if (!$usuario_nuevo) { $html .= 'Se detectaron problemas. No se pudo registrar.'; }; } else { $html .= 'Para iniciar sesión o registrarse visite <a href="/concursocial/sesion">mi sesión</a><br/>'; if ($user->uid != 0) drupal_goto('user'); } if ($usuario_nuevo) { $user = $usuario_nuevo; drupal_goto('user'); } return $html; }
source share