PHP Class Twitter\Intents\Tweet

Mostrar archivo Open project: twitter/wordpress Class Usage Examples

Protected Properties

Property Type Description
$hashtags Hashtags to include in the Tweet
$in_reply_to Parent Tweet identifier
$related May be presented as a suggested account to follow after the Tweet is published
$text Pre-populated Tweet text
$url Share a URL
$validate_inputs Validate passed variables before storing
$via Associate a Tweet with an source Twitter account such as the username of your website

Public Methods

Method Description
addHashtag ( string $hashtag ) : __CLASS__ Add a hashtag
addRelated ( string $username, string $label = '' ) : __CLASS__ Add a related Twitter account
disableValidation ( ) : __CLASS__ Do not validate inputs
enableValidation ( ) : __CLASS__ Validate inputs
fromArray ( array $values ) : __CLASS__ Construct a new Tweet intent object from an options array
getHashtags ( ) : array Get a list of hashtags stored for the Tweet
getIntentURL ( ) : string Tweet intent URL
getRelated ( ) : array Get related Twitter usernames
getVia ( ) : string Get the stored via value
isHTTPURL ( string $url ) : boolean Is the passed URL an absolute URL using the HTTP or HTTPS scheme?
setInReplyTo ( string $tweet_id ) : __CLASS__ Define a parent Tweet by ID
setText ( string $text ) : __CLASS__ Pre-populate Tweet text
setURL ( string $url ) : __CLASS__ Share a URL
setVia ( string $username ) : __CLASS__ Associate Tweet with a source account
shouldValidate ( ) : boolean Should data be validated before setting?
toQueryParameters ( ) : array Convert parameters into an array prepped for use in query parameters (underscores) or data-* attributes (dashed)

Method Details

addHashtag() public method

Add a hashtag
Since: 1.0.0
public addHashtag ( string $hashtag ) : __CLASS__
$hashtag string hashtag
return __CLASS__ support chaining

addRelated() public method

Add a related Twitter account
Since: 1.0.0
public addRelated ( string $username, string $label = '' ) : __CLASS__
$username string Twitter username
$label string brief description of how the account relates to the Tweet content
return __CLASS__ support chaining

disableValidation() public method

Disabling validation may speed up Web Intent generation but may also cause user-facing issues
Since: 1.0.0
public disableValidation ( ) : __CLASS__
return __CLASS__ support chaining

enableValidation() public method

Validate inputs
Since: 1.0.0
public enableValidation ( ) : __CLASS__
return __CLASS__ support chaining

fromArray() public static method

Construct a new Tweet intent object from an options array
Since: 1.0.0
public static fromArray ( array $values ) : __CLASS__
$values array options array { @type string option name @type string|int|bool option value }
return __CLASS__ object initialized based on passed array values

getHashtags() public method

Get a list of hashtags stored for the Tweet
Since: 1.0.0
public getHashtags ( ) : array
return array hashtags { @type string hashtag }

getIntentURL() public method

Tweet intent URL
Since: 1.0.0
public getIntentURL ( ) : string
return string Tweet intent URL with query parameters

getRelated() public method

Get related Twitter usernames
Since: 1.0.0
public getRelated ( ) : array
return array { @type string username in lowercase @type string description of how the username relates to Tweet content }

getVia() public method

Get the stored via value
Since: 1.0.1
public getVia ( ) : string
return string source Twitter account username

isHTTPURL() public static method

Is the passed URL an absolute URL using the HTTP or HTTPS scheme?
Since: 1.0.0
public static isHTTPURL ( string $url ) : boolean
$url string URL to test
return boolean true if URL was parsed and contains a HTTP or HTTPs scheme

setInReplyTo() public method

Define a parent Tweet by ID
Since: 1.0.0
public setInReplyTo ( string $tweet_id ) : __CLASS__
$tweet_id string Parent Tweet ID
return __CLASS__ support chaining

setText() public method

Pre-populate Tweet text
Since: 1.0.0
public setText ( string $text ) : __CLASS__
$text string Tweet text
return __CLASS__ support chaining

setURL() public method

Share a URL
Since: 1.0.0
public setURL ( string $url ) : __CLASS__
$url string absolute URL
return __CLASS__ support chaining

setVia() public method

Associate Tweet with a source account
Since: 1.0.0
public setVia ( string $username ) : __CLASS__
$username string Twitter username
return __CLASS__ support chaining

shouldValidate() public method

Should data be validated before setting?
Since: 1.0.0
public shouldValidate ( ) : boolean
return boolean validate inputs

toQueryParameters() public method

Convert parameters into an array prepped for use in query parameters (underscores) or data-* attributes (dashed)
Since: 1.0.0
public toQueryParameters ( ) : array
return array Tweet parameters { @type string Tweet parameter @type string parameter value }

Property Details

$hashtags protected_oe property

Hashtags to include in the Tweet
Since: 1.0.0
protected $hashtags

$in_reply_to protected_oe property

Parent Tweet identifier
Since: 1.0.0
protected $in_reply_to

$text protected_oe property

Pre-populated Tweet text
Since: 1.0.0
protected $text

$url protected_oe property

Share a URL
Since: 1.0.0
protected $url

$validate_inputs protected_oe property

Validate passed variables before storing
Since: 1.0.0
protected $validate_inputs

$via protected_oe property

Associate a Tweet with an source Twitter account such as the username of your website
Since: 1.0.0
protected $via