使用3.2在twitter登录中找不到“App \ Controller \ TwitterOAuth”类

时间:2016-05-11 13:12:40

标签: cakephp twitter-oauth cakephp-3.0

我是cakephp的新手,我在这里为我的网站做Twitter登录但是,我无法继续进行上述错误即将到来。

我已经给出了这样的路径

  public function beforeFilter(Event $event) {

require_once(ROOT . '/vendor/' . DS . '/twitteroauth/' . 'twitteroauth.php');


    define('CONSUMER_KEY', '10282039035454927010');
    define('CONSUMER_SECRET', 'ed716c05cccd08c78050e2b58b916c2fb7f');
    define('OAUTH_CALLBACK', 'http://localhost/videoportal');
 public function twitterlogin() {
        $this->layout = 'innerdefault';
        /* Start session and load library. */
        /* Build TwitterOAuth object with client credentials. */
        $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
        /* Get temporary credentials. */
        $request_token = $connection->getRequestToken(OAUTH_CALLBACK);
        //print_r($request_token); exit;
        /* Save temporary credentials to session. */
        $_SESSION['oauth_token'] = $token = $request_token['oauth_token'];
        //echo $_SESSION['oauth_token']; exit;
        $_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];

        /* If last connection failed don't display authorization link. */
        ///print_r($connection->http_code); exit;
        switch ($connection->http_code) {
            case 200:
                /* Build authorize URL and redirect user to Twitter. */
                $url = $connection->getAuthorizeURL($token);
                $this->redirect($url);
                break;
            default:
                /* Show notification if something went wrong. */
                echo 'Could not connect to Twitter. Refresh the page or try again later.';
        }
        //exit;
    }

请建议我。谢谢你

1 个答案:

答案 0 :(得分:-1)

您是否使用composer安装了TwitterOAuth插件?