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
파일 보기 프로젝트 열기: ngnpope/twitter-text-php 1 사용 예제들

공개 메소드들

메소드 설명
__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.