<commit_before><?php
/**
 * TwitterDataSourceForCakePHP
 * 
 * Copyright (c) 2014 <NAME>
 * 
 * Licensed under MIT License.
 * See the file "LICENSE" for more details.
 */

App::uses('HttpSocket', 'Network/Http');

class TwitterSource extends DataSource {
	
	public $description = "DataSource for TwitterAPI 1.1";
	
	// default configuration
	public $config = array(
		'api_url_base' => 'https://api.twitter.com/1.1/',
		'oauth_url_base' => 'https://api.twitter.com/oauth/',
		'oauth_consumer_key' => 'api-key',
		'api_secret' => 'secret',
		'user-agent' => 'Twitter Source'
	);
	
	// user specific setting : usually these variables should be changed dynamically.
	public $oauthToken = '';
	public $oauthTokenSecret = '';
	
	
	// debug setting
	public $withDebugLog = true;
	
	
	
	public function __construct($config) {
		parent::__construct($config);
		$this->Http = new HttpSocket();
	}
	
	// =========================================================
	// =========================================================
	// ===== required methods to implement DataSource
	// =========================================================
	// =========================================================
	
	public function describe($model) {
		return array();
	}
	
	public function listSources($data = null) {
		return null;
	}
	
	public function calculate($model, $func, $params) {
		return '';
	}
	
	
	// =========================================================
	// =========================================================
	// ===== high-level APIs
	// ===== before calling these methods, set $oauthToken & $oauthTokenSecret if required.
	// =========================================================
	// =========================================================
	public function verifyCredentials($params) {
		// see https://dev.twitter.com/docs/api/1.1/get/account/verify_credentials for contents of $params
		<commit_msg>supported debug log on/off setting<commit_after><?php
/**
 * TwitterDataSourceForCakePHP
 * 
 * Copyright (c) 2014 <NAME>
 * 
 * Licensed under MIT License.
 * See the file "LICENSE" for more details.
 */

App::uses('HttpSocket', 'Network/Http');

class TwitterSource extends DataSource {
	
	public $description = "DataSource for TwitterAPI 1.1";
	
	// default configuration
	public $config = array(
		'api_url_base' => 'https://api.twitter.com/1.1/',
		'oauth_url_base' => 'https://api.twitter.com/oauth/',
		'oauth_consumer_key' => 'api-key',
		'api_secret' => 'secret',
		'user-agent' => 'Twitter Source',
		'withDebugLog' => true,
	);
	
	// user specific setting : usually these variables should be changed dynamically.
	public $oauthToken = '';
	public $oauthTokenSecret = '';
	
	
	// debug setting
	public $withDebugLog = true;
	
	
	
	public function __construct($config) {
		parent::__construct($config);
		$this->Http = new HttpSocket();
		$this->withDebugLog = !empty($config['withDebugLog']);
	}
	
	// =========================================================
	// =========================================================
	// ===== required methods to implement DataSource
	// =========================================================
	// =========================================================
	
	public function describe($model) {
		return array();
	}
	
	public function listSources($data = null) {
		return null;
	}
	
	public function calculate($model, $func, $params) {
		return '';
	}
	
	
	// =========================================================
	// =========================================================
	// ===== high-level APIs
	// ===== before calling these methods, set $oauthToken & $oauthTokenSecret if required.
	// =========================================================
	// =========================================================
	public function verifyCredentials($params) {
		// see https://dev.twitter.com/docs/api/1.1/get/account/verify_credentials for contents of $params
		
{'fraction_non_alphanumeric': 0.35207326380055964, 'fraction_numerical': 0.005087763927753753, 'mean_word_length': 4.756954612005856, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4188428', 'n_tokens_mistral': 1117, 'n_tokens_neox': 991, 'n_words': 234}