PHP Класс 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}.
Автор: Mike Cochrane ([email protected])
Автор: Nick Pope ([email protected])
Наследование: extends Twitter_Regex
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
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.

Описание методов

__construct() публичный Метод

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

create() публичный статический Метод

Provides fluent method chaining.
См. также: __construct()
public static create ( string $tweet ) : Twitter_Extractor
$tweet string The tweet to be converted.
Результат Twitter_Extractor

extract() публичный Метод

Extracts all parts of a tweet and returns an associative array containing the extracted elements.
public extract ( ) : array
Результат array The elements in the tweet.

extractCashtags() публичный Метод

Extracts all the cashtags from the tweet.
public extractCashtags ( ) : array
Результат array The cashtag elements in the tweet.

extractCashtagsWithIndices() публичный Метод

Extracts all the cashtags and the indices they occur at from the tweet.
public extractCashtagsWithIndices ( ) : array
Результат array The cashtag elements in the tweet.

extractHashtags() публичный Метод

Extracts all the hashtags from the tweet.
public extractHashtags ( ) : array
Результат array The hashtag elements in the tweet.

extractHashtagsWithIndices() публичный Метод

Extracts all the hashtags and the indices they occur at from the tweet.
public extractHashtagsWithIndices ( ) : array
Результат array The hashtag elements in the tweet.

extractMentionedUsernames() публичный Метод

A mention is an occurrence of a username anywhere in a tweet.
public extractMentionedUsernames ( ) : array
Результат array The usernames elements in the tweet.

extractMentionedUsernamesOrListsWithIndices() публичный Метод

Extracts all the usernames and the indices they occur at from the tweet.
public extractMentionedUsernamesOrListsWithIndices ( ) : array
Результат array The username elements in the tweet.

extractMentionedUsernamesWithIndices() публичный Метод

Extracts all the usernames and the indices they occur at from the tweet.
public extractMentionedUsernamesWithIndices ( ) : array
Результат array The username elements in the tweet.

extractRepliedUsernames() публичный Метод

A reply is an occurrence of a username at the beginning of a tweet.
public extractRepliedUsernames ( ) : array
Результат array The usernames replied to in a tweet.

extractURLs() публичный Метод

Extracts all the URLs from the tweet.
public extractURLs ( ) : array
Результат array The URL elements in the tweet.

extractURLsWithIndices() публичный Метод

Extracts all the URLs and the indices they occur at from the tweet.
public extractURLsWithIndices ( ) : array
Результат array The URLs elements in the tweet.

fixMultiByteIndices() защищенный статический Метод

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.