Constants

META_PROPERTIES_IMAGE

META_PROPERTIES_IMAGE =array('og:image', 'og:image:url', 'og:image:secure_url', 'twitter:image', 'twitter:image:src', 'lp:image')

META_PROPERTIES_TITLE

META_PROPERTIES_TITLE =array('og:title', 'twitter:title', 'lp:title', 'dcterms.title', 'article:title', 'headline', 'article.headline', 'parsely-title')

XML_XPATH_IMAGE

XML_XPATH_IMAGE =array('//itunes:image/@href')

XML_XPATH_TITLE

XML_XPATH_TITLE =array('//channel/title')

Properties

$callbacks

$callbacks :array<mixed,callable>

Callbacks.

Type

array<mixed,callable>

$selectorSyntaxFunctions

$selectorSyntaxFunctions :array<mixed,callable>

Callbacks for `SelectorSyntaxAttributeFunction`.

Type

array<mixed,callable>

$headParserResult

$headParserResult :array

Result of the last `$headParser` execution.

Type

array

Methods

__construct()

__construct()

C'tor.

addCallback()

addCallback(callable  $callback)

Add a callable. The first parameter is the HTML string and should return HTML.

Parameters

callable $callback

addSelectorSyntaxFunction()

addSelectorSyntaxFunction(string  $functionName,callable  $callback)

Add a callable for a Selector Syntax function.

The callback gets the following parameters and expects boolean as result:

SelectorSyntaxAttributeFunction $function, SelectorSyntaxMatch $match, mixed $value

Parameters

string $functionName
callable $callback

modifyAny()

modifyAny(string  $mixed)

Allows to parse and modify any content. This could be e.g. a JSON string (each value gets iterated and parsed if it is a HTML).

Parameters

string $mixed

modifyHtml()

modifyHtml(string  $html)

Allow to parse and modify a given HTML string.

Parameters

string $html

getSelectorSyntaxFunction()

getSelectorSyntaxFunction(string  $functionName)

Get a defined selector syntax function by name.

Parameters

string $functionName

extractFromUrls()

extractFromUrls(array<mixed,string>  $urls)

Send multiple HTTP requests simultaneously and return a map of URL to image preview URL and additional data.

If there could not be found an image, the requested URL does not exist in the result array.

Parameters

array<mixed,string> $urls

convertUrlToThumbnailFromXml()

convertUrlToThumbnailFromXml(string  $body)

Use the power of `SimpleXMLElement` and XPath to extract title and images from a given XML body.

Parameters

string $body

extractXpathResToSingleValue()

extractXpathResToSingleValue(array<mixed,static>|false|null  $result)

Check if a given `->xpath()` result is present and extract a single value.

Parameters

array<mixed,static>|false|null $result

convertUrlToThumbnailFromResponse()

convertUrlToThumbnailFromResponse(string  $requestedUrl,string  $contentType,string  $body): array|false

Pass in some response infos about a requested URL and we will try to detect a thumbnail URL and other infos like title and description for you.

Parameters

string $requestedUrl
string $contentType
string $body

Returns

array|false