在我的Controller中使用外部类

Im working on my first project in CodeIgniter and I wonder How can I use my class from library in my Controller.

libraries/Twitterclass.php:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Twetterclass {

public function __construct($hashtag, $tweet_id)
{
    require_once('TwitterAPIExchange.php');

    //There is my working code

    //I want to make use of this $n in my Controller
    return $n;

}
}

/* End of file Twetterclass.php */

My Controller:

    public function microtweets()
    {
        $params = array('hashtag' => 'somehashtag', 'tweet_id' => '673899616799191040');
        $data['count_tweets'] = $this->load->library('Twetterclass', $params);

        $this->load->view('tweets', $data);
    }

I want to use his extended class in my controller and work there on this $n value or for example display it in my View.

I get few errors:

A PHP Error was encountered

Severity: Warning

Message: Missing argument 2 for Twetterclass::__construct(), called in /home/jail/kg7dad5/home/kg7dad5/domains/badzlepszy.pl/public_html/coinmonitor/system/core/Loader.php on line 1246 and defined

Filename: libraries/Twetterclass.php

Line Number: 5

Backtrace:

File: /application/libraries/Twetterclass.php Line: 5 Function: _error_handler

File: /application/controllers/Cointweet.php Line: 24 Function: library

File: /public_html/coinmonitor/index.php Line: 292 Function: require_once

first try to debug parameter you passed in constructor

public function __construct($hashtag, $tweet_id)
{
   echo $hashtag;
   echo $tweet_id;
   die; 
}

according to your code, change like this,

public function __construct($arr)
{
   echo $arr['hashtag'];
   echo $arr['tweet_id'];
   exit; 
}

Because you are passing 1 array, so access in library with array index.