<commit_before>Examples
========

- `CK` means *consumer\_key*.
- `CS` means *consumer\_secret*.
- `AT` means *access\_token*.
- `AS` means *access\_token\_secret*.

## Level-1: Simple GUI application for your own account

### Display home timeline

```html+php
<?php

// Load this library.
require 'TwistOAuth.php';

// Prepare simple wrapper function for htmlspecialchars.
function h($str) {
    return htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
}

// Set default HTTP status code.
$code = 200;

// Set your timezone.
date_default_timezone_set('Asia/Tokyo');

try {
    
    // Generate your TwistOAuth object.
    $to = new TwistOAuth('CK', 'CS', 'AT', 'AS');
    
    // Get tweets on your home timeline within 5.
    // This method may throw TwistException.
    $statuses = $to->get('statuses/home_timeline', array('count' => 5));
    
} catch (TwistException $e) {
    
    // Set error message.
    $error = $e->getMessage();
    
    // Overwrite HTTP status code.
    // The exception code will be zero when it thrown before accessing Twitter, we need to change it into 500.
    $code = $e->getCode() > 0 ? $e->getCode() : 500;
    
}

// Send charset and HTTP status code to your browser.
header('Content-Type: text/html; charset=utf-8', true, $code);

?>
<!DOCTYPE html>
<html>
<body>
  <h1>Your home timeline</h1>
<?php if (isset($error)): ?>
  <p style="color:red;"><?=h($error)?></p>
<?php endif; ?>
<?php if (!empty($statuses)): ?>
<?php foreach ($statues as $status): ?>
  <p>
    user_id: <?=$status->user->id_str?><br>
    screen_name: @<?=$status->user->screen_name?><br>
    name: <?=h($status->user->name)?><br>
    text: <?=$status->text?><br>
    time: <?=strtotime($status->created_at)?><br>
  </p>
<?php endforeach; ?>
<?php endif; ?>
</body>
</html>
```

### Update tweets<commit_msg>Fixed Example<commit_after>Examples
========

- `CK` means *consumer\_key*.
- `CS` means *consumer\_secret*.
- `AT` means *access\_token*.
- `AS` means *access\_token\_secret*.

## Level-1: Simple GUI application for your own account

### Display home timeline

```html+php
<?php

// Load this library.
require 'TwistOAuth.php';

// Prepare simple wrapper function for htmlspecialchars.
function h($str) {
    return htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
}

// Set default HTTP status code.
$code = 200;

// Set your timezone.
date_default_timezone_set('Asia/Tokyo');

try {
    
    // Generate your TwistOAuth object.
    $to = new TwistOAuth('CK', 'CS', 'AT', 'AS');
    
    // Get tweets on your home timeline within 5.
    // This method may throw TwistException.
    $statuses = $to->get('statuses/home_timeline', array('count' => 5));
    
} catch (TwistException $e) {
    
    // Set error message.
    $error = $e->getMessage();
    
    // Overwrite HTTP status code.
    // The exception code will be zero when it thrown before accessing Twitter, we need to change it into 500.
    $code = $e->getCode() > 0 ? $e->getCode() : 500;
    
}

// Send charset and HTTP status code to your browser.
header('Content-Type: text/html; charset=utf-8', true, $code);

?>
<!DOCTYPE html>
<html>
<body>
  <h1>Your home timeline</h1>
<?php if (isset($error)): ?>
  <p style="color:red;"><?=h($error)?></p>
<?php endif; ?>
<?php if (!empty($statuses)): ?>
<?php foreach ($statuses as $status): ?>
  <p>
    user_id: <?=$status->user->id_str?><br>
    screen_name: @<?=$status->user->screen_name?><br>
    name: <?=h($status->user->name)?><br>
    text: <?=$status->text?><br>
    time: <?=strtotime($status->created_at)?><br>
  </p>
<?php endforeach; ?>
<?php endif; ?>
</body>
</html>
```

### Update tweets
{'fraction_non_alphanumeric': 0.19475862068965516, 'fraction_numerical': 0.009379310344827587, 'mean_word_length': 3.521197007481297, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 89, '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': '6914796', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1237, 'n_words': 348}