Skip to content

Instantly share code, notes, and snippets.

@zx1986
Last active November 24, 2015 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zx1986/9b5ae39ab2eaf49d4291 to your computer and use it in GitHub Desktop.
Save zx1986/9b5ae39ab2eaf49d4291 to your computer and use it in GitHub Desktop.
如何把第三方的 Class 包到 CodeIgniter Libraries 中,方便 CodeIgniter $CI->load->libraries
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class PHPList {
public function __construct($config = array())
{
if (!empty($config))
{
include_once('phpListRESTApiClient.php');
return new phpListRESTApiClient($config['api_url'], $config['id'], $config['pw']);
}
else
echo 'Need to initial with an array like: $config("api_url" => string, "id" => string, "pw" => string);'
}
}
/* End of file PHPList.php */
@crazylion
Copy link

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

  public function __construct($config = array())
  {
    if (!empty($config))
    {
      include_once('phpListRESTApiClient.php');
      $this->config=$config;
    }
    else
      echo 'Need to initial with an array like: $config("api_url" => string, "id" => string, "pw" => string);'
  }

public init(){
return new phpListRESTApiClient($this->config['api_url'], $this->config['id'], $this->config['pw']);
}
}

@zx1986
Copy link
Author

zx1986 commented Nov 24, 2015

感謝大神賜教!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment