authorize() public méthode

public authorize ( $username, $password = null, $service = 'amy' )
Exemple #1
0
 public function on_user_sign_in($pars)
 {
     try {
         $user = new AmyUser($this->configuration);
         $user->authorize($pars['username'], $pars['password'], 'amy');
         $user->create_session();
         self::setResult($user);
     } catch (Exception $e) {
         self::raiseError('Unable to login: ' . $e->getMessage());
     }
 }
    if (!$facebook->api_client->users_isAppAdded()) {
        $facebook->redirect($facebook->get_add_url());
    }
} catch (Exception $e) {
    // this will clear cookies for your application and
    // redirect them to a login prompt
    $facebook->set_user(null, null);
    $facebook->redirect($callback_url);
}
if (!isset($_REQUEST['iframe_skipped'])) {
    echo '<html><head><body><script type="text/javascript">top.location.href="' . $callback_url . '&auth_token=' . $_GET['auth_token'] . '&iframe_skipped=true' . '" + ((top.opener&&top.opener.location.host==\'www.april-child.com\') ? "&external_service=true" : "");</script></body></html>';
    exit;
}
$amy_user = new AmyUser($_AMY_CONF);
try {
    $amy_user->authorize($user, null, 'facebook');
} catch (Exception $e) {
}
if (!$amy_user->is_authorized()) {
    // first time visit from Facebook
    // let's register user
    try {
        $user_info = $facebook->api_client->users_getInfo(array($user), array('name', 'pic_square'));
        $credentials = array('nickname' => $user_info[0]['name'], 'picture' => $user_info[0]['pic_square']);
        $amy_user->register($user, null, 'facebook', $credentials);
    } catch (Exception $e) {
    }
} else {
    if ($_REQUEST['external_service']) {
        echo '<html><head><body><script type="text/javascript">';
        echo 'var user = {id:' . $amy_user->userId . ', username:"******", service:"' . $amy_user->service . '", credentials:{nickname:"' . $amy_user->credentials['nickname'] . '", picture:"' . $amy_user->credentials['picture'] . '", bio:""}};';