3

私はこのプラグインと混同しています。

デモをコピーして貼り付けるだけですが、Facebook に接続しようとすると次のエラーが表示されます。

The page isn't redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

完全なコード:

<?php

class ExamplesController extends AppController {

  public $components = array(
    'Auth'=> array(
      'loginAction' => array(
        'controller' => 'examples',
        'action'     => 'login'
      ),
      'loginRedirect' => array(
        'controller' => 'examples',
        'action'     => 'my_account'
      ),
      'authError' => 'Did you really think you are allowed to see that?',
      'authenticate' => array(
        'FacebookAuth.Facebook' => array(
          'fields' => array(
            'username' => 'email',
                'password' => 'password'
          )
        )
      )
    )
  );

    public function index() {
    }

  public function beforeFilter()
  {
    parent::beforeFilter();

    $this->Auth->authenticate['FacebookAuth.Facebook']['application'] = array(
      'id'     => Configure::read('facebook.app_id'),
      'secret' => Configure::read('facebook.app_secret')
    );

    $this->Auth->allowedActions = array_merge($this->Auth->allowedActions, array('login'));
  }

  public function login()
  {
    if (!$this->Auth->login()) {
      /**
       * Get config for Facebook redirect
       */
      $clientId    = Configure::read('facebook.app_id');
      $permissions = implode(',', Configure::read('facebook.permissions'));
      $redirect    = Router::url(false, true);
      $csrfToken   = CakeSession::read('FacebookAuthCSRF');

      $this->redirect(Configure::read('facebook.oauth_dialg_url') . '?client_id=' . $clientId . '&redirect_uri=' . $redirect . '&scope=' . $permissions . '&state=' . $csrfToken);
    } else {
      $this->redirect(array('action' => 'my_account'));
    }
  }

  public function my_account()
  {
    var_dump($this->Auth->user());
    die();
  }
}

課題は、プラグインを機能させる方法を理解することです。


更新: OK、私はこの URL を持っています (エリオットに感謝):

http://someHost/?client_id=4003xx16796&redirect_uri=http://localhost/cake/users/login&scope=email&state=f96419881df77cdc689e6c43c131cf3b

では、URL はどうすればよいのでしょうか。次のステップ、基本的に。私が持っているのはログインボタンだけです。クリックすると、上記のデモのように URL が変更されますが、アクションはありません。応答は空です。

私はすでにこれを読みました

4

1 に答える 1

2

問題は

Configure::read('facebook.oauth_dialg_url')

読むべき:

Configure::read('facebook.oauth_dialog_url') 

また、bootstrap.php で適切な Configure::write コマンドを作成していることを確認してください。

Configure::write('facebook.oauth_dialog_url', 'http://some-value.com/path/to/url');
于 2012-08-17T12:45:49.943 に答える