Embera\Embera::getUrlInfo PHP Method

getUrlInfo() public method

Finds all the information about a url (or a collection of urls)
public getUrlInfo ( string | array $body = null ) : array
$body string | array An array or string with urls
return array
    public function getUrlInfo($body = null)
    {
        $results = array();
        if ($providers = $this->getProviders($body)) {
            foreach ($providers as $url => $service) {
                $results[$url] = $service->getInfo();
                $this->errors = array_merge($this->errors, $service->getErrors());
            }
        }
        return array_filter($results);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Replace embeddable URLs with the embed code.
  *
  * @param string $text
  *
  * @return string
  */
 public static function OEmbed($text)
 {
     $embera = new Embera();
     if ($data = $embera->getUrlInfo($text)) {
         $table = [];
         foreach ($data as $url => $service) {
             if (!empty($service['html'])) {
                 $table[$url] = $service['html'];
             }
         }
         foreach ($table as $url => $replacement) {
             $text = preg_replace('~(?<![\'\\"])' . preg_quote($url) . '(?![\'\\"])(?!\\</a\\>)~', $replacement, $text);
         }
     }
     return $text;
 }
All Usage Examples Of Embera\Embera::getUrlInfo