<commit_before><?php

// Get parameters from AJAX request
$x = $_GET['x'] + 1;
$title = urlencode($_GET['title']);

// Load required lib files
require_once('../twitteroauth/twitteroauth.php');
require_once('../config.php');

// Prepare a connection using a preset token
function getConnectionWithAccessToken($oauth_token, $oauth_token_secret) {
  $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $oauth_token, $oauth_token_secret);
  return $connection;
}

// Open connection
$connection = getConnectionWithAccessToken(OAUTH_TOKEN, OAUTH_TOKEN_SECRET);

// Pull sample content from Twitter
$content = $connection->get("search/tweets",
	array(
		'q' => $title,
		'lang' => 'en',
		'count' => '5',
		'result_type' => 'mixed',
		'include_entities' => 'true'
	)
);

// Print index for parent script to accurately place data in the DOM
// Note: Elements with class "movie" are referenced by index
print '{ "x": ' . $x . ', ';

// Remove first character from the encoded data (i.e, the opening bracket, '{') to prevent parsing error
print substr( json_encode($content), 1 );
// print ' }';

?><commit_msg>Note to add validation requirements to twitter.php<commit_after><?php

// ADD VALIDATION REQUIREMENTS

// Get parameters from AJAX request
$x = $_GET['x'] + 1;
$title = urlencode($_GET['title']);

// Load required lib files
require_once('../twitteroauth/twitteroauth.php');
require_once('../config.php');

// Prepare a connection using a preset token
function getConnectionWithAccessToken($oauth_token, $oauth_token_secret) {
  $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $oauth_token, $oauth_token_secret);
  return $connection;
}

// Open connection
$connection = getConnectionWithAccessToken(OAUTH_TOKEN, OAUTH_TOKEN_SECRET);

// Pull sample content from Twitter
$content = $connection->get("search/tweets",
	array(
		'q' => $title,
		'lang' => 'en',
		'count' => '5',
		'result_type' => 'mixed',
		'include_entities' => 'true'
	)
);

// Print index for parent script to accurately place data in the DOM
// Note: Elements with class "movie" are referenced by index
print '{ "x": ' . $x . ', ';

// Remove first character from the encoded data (i.e, the opening bracket, '{') to prevent parsing error
print substr( json_encode($content), 1 );

?>
{'fraction_non_alphanumeric': 0.1479367866549605, 'fraction_numerical': 0.0026338893766461808, 'mean_word_length': 4.798982188295166, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, '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': '4970201', 'n_tokens_mistral': 755, 'n_tokens_neox': 729, 'n_words': 212}