PHP Class Twitter_Extractor, twitter-text-php

Parses tweets and extracts URLs, usernames, username/list pairs and hashtags. Originally written by {@link http://github.com/mikenz Mike Cochrane}, this is based on code by {@link http://github.com/mzsanford Matt Sanford} and heavily modified by {@link http://github.com/ngnpope Nick Pope}.
Author: Mike Cochrane ([email protected])
Author: Nick Pope ([email protected])
Inheritance: extends Twitter_Regex
Afficher le fichier Open project: ngnpope/twitter-text-php Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( string $tweet ) Reads in a tweet to be parsed and extracts elements from it.
create ( string $tweet ) : Twitter_Extractor Provides fluent method chaining.
extract ( ) : array Extracts all parts of a tweet and returns an associative array containing the extracted elements.
extractCashtags ( ) : array Extracts all the cashtags from the tweet.
extractCashtagsWithIndices ( ) : array Extracts all the cashtags and the indices they occur at from the tweet.
extractHashtags ( ) : array Extracts all the hashtags from the tweet.
extractHashtagsWithIndices ( ) : array Extracts all the hashtags and the indices they occur at from the tweet.
extractMentionedUsernames ( ) : array Extract all the usernames from the tweet.
extractMentionedUsernamesOrListsWithIndices ( ) : array Extracts all the usernames and the indices they occur at from the tweet.
extractMentionedUsernamesWithIndices ( ) : array Extracts all the usernames and the indices they occur at from the tweet.
extractRepliedUsernames ( ) : array Extract all the usernames replied to from the tweet.
extractURLs ( ) : array Extracts all the URLs from the tweet.
extractURLsWithIndices ( ) : array Extracts all the URLs and the indices they occur at from the tweet.

Méthodes protégées

Méthode Description
fixMultiByteIndices ( string &$tweet, array &$matches, array &$results, array $keys, integer $tweak = 1 ) Processes an array of matches and fixes up the offsets to support multibyte strings. This needs to be done due to the state of unicode support in PHP.

Method Details

__construct() public méthode

Extracts various parts of a tweet including URLs, usernames, hashtags...
public __construct ( string $tweet )
$tweet string The tweet to extract.

create() public static méthode

Provides fluent method chaining.
See also: __construct()
public static create ( string $tweet ) : Twitter_Extractor
$tweet string The tweet to be converted.
Résultat Twitter_Extractor

extract() public méthode

Extracts all parts of a tweet and returns an associative array containing the extracted elements.
public extract ( ) : array
Résultat array The elements in the tweet.

extractCashtags() public méthode

Extracts all the cashtags from the tweet.
public extractCashtags ( ) : array
Résultat array The cashtag elements in the tweet.

extractCashtagsWithIndices() public méthode

Extracts all the cashtags and the indices they occur at from the tweet.
public extractCashtagsWithIndices ( ) : array
Résultat array The cashtag elements in the tweet.

extractHashtags() public méthode

Extracts all the hashtags from the tweet.
public extractHashtags ( ) : array
Résultat array The hashtag elements in the tweet.

extractHashtagsWithIndices() public méthode

Extracts all the hashtags and the indices they occur at from the tweet.
public extractHashtagsWithIndices ( ) : array
Résultat array The hashtag elements in the tweet.

extractMentionedUsernames() public méthode

A mention is an occurrence of a username anywhere in a tweet.
public extractMentionedUsernames ( ) : array
Résultat array The usernames elements in the tweet.

extractMentionedUsernamesOrListsWithIndices() public méthode

Extracts all the usernames and the indices they occur at from the tweet.
public extractMentionedUsernamesOrListsWithIndices ( ) : array
Résultat array The username elements in the tweet.

extractMentionedUsernamesWithIndices() public méthode

Extracts all the usernames and the indices they occur at from the tweet.
public extractMentionedUsernamesWithIndices ( ) : array
Résultat array The username elements in the tweet.

extractRepliedUsernames() public méthode

A reply is an occurrence of a username at the beginning of a tweet.
public extractRepliedUsernames ( ) : array
Résultat array The usernames replied to in a tweet.

extractURLs() public méthode

Extracts all the URLs from the tweet.
public extractURLs ( ) : array
Résultat array The URL elements in the tweet.

extractURLsWithIndices() public méthode

Extracts all the URLs and the indices they occur at from the tweet.
public extractURLsWithIndices ( ) : array
Résultat array The URLs elements in the tweet.

fixMultiByteIndices() protected static méthode

Processes an array of matches and fixes up the offsets to support multibyte strings. This needs to be done due to the state of unicode support in PHP.
protected static fixMultiByteIndices ( string &$tweet, array &$matches, array &$results, array $keys, integer $tweak = 1 )
$tweet string The tweet being matched.
$matches array The matches from the regular expression match.
$results array The extracted results from the matches.
$keys array The list of array keys to be added.
$tweak integer An amount to adjust the end index by.