oscarotero / Embed

Get info from any web service or page
MIT License
2.08k stars 310 forks source link

some functions are not recognized #352

Closed byndstd closed 4 years ago

byndstd commented 4 years ago

I try the to return some urls but I get Call to undefined function Embed\isHttp() I did comment to : if (!isHttp($uri)) { throw new InvalidArgumentException(sprintf('Uri string must use http or https scheme (%s)', $uri)); }

I get Call to undefined function Embed\resolveUri() I did change return resolveUri($this->uri, $uri); to return $this->uri

I get Call to undefined function Embed\clean()

oscarotero commented 4 years ago

These functions are in this file: https://github.com/oscarotero/Embed/blob/master/src/functions.php and are loaded automatically by composer.

byndstd commented 4 years ago

I did delete everything and installed all from beginning after I try exactly step by step

use Embed\Embed;
$embed = new Embed();
//Load any url:
$info = $embed->get($url);

All what I get as return : I tried with many links youtube, pinterest and many other webs All are working on your test web : https://oscarotero.com/embed/demo/ var_dump($info);


object(Embed\Adapters\Youtube\Extractor)#155 (29) {
  ["request":"Embed\Extractor":private]=>
  object(Nyholm\Psr7\Request)#151 (7) {
    ["headers":"Nyholm\Psr7\Request":private]=>
    array(3) {
      ["Host"]=>
      array(1) {
        [0]=>
        string(15) "www.youtube.com"
      }
      ["User-Agent"]=>
      array(1) {
        [0]=>
        string(82) "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:73.0) Gecko/20100101 Firefox/73.0"
      }
      ["Cache-Control"]=>
      array(1) {
        [0]=>
        string(9) "max-age=0"
      }
    }
    ["headerNames":"Nyholm\Psr7\Request":private]=>
    array(3) {
      ["host"]=>
      string(4) "Host"
      ["user-agent"]=>
      string(10) "User-Agent"
      ["cache-control"]=>
      string(13) "Cache-Control"
    }
    ["protocol":"Nyholm\Psr7\Request":private]=>
    string(3) "1.1"
    ["stream":"Nyholm\Psr7\Request":private]=>
    NULL
    ["method":"Nyholm\Psr7\Request":private]=>
    string(3) "GET"
    ["requestTarget":"Nyholm\Psr7\Request":private]=>
    NULL
    ["uri":"Nyholm\Psr7\Request":private]=>
    object(Nyholm\Psr7\Uri)#152 (7) {
      ["scheme":"Nyholm\Psr7\Uri":private]=>
      string(5) "https"
      ["userInfo":"Nyholm\Psr7\Uri":private]=>
      string(0) ""
      ["host":"Nyholm\Psr7\Uri":private]=>
      string(15) "www.youtube.com"
      ["port":"Nyholm\Psr7\Uri":private]=>
      NULL
      ["path":"Nyholm\Psr7\Uri":private]=>
      string(6) "/watch"
      ["query":"Nyholm\Psr7\Uri":private]=>
      string(13) "v=0YVwtb8pZZY"
      ["fragment":"Nyholm\Psr7\Uri":private]=>
      string(0) ""
    }
  }
  ["response":"Embed\Extractor":private]=>
  object(Nyholm\Psr7\Response)#156 (6) {
    ["reasonPhrase":"Nyholm\Psr7\Response":private]=>
    string(2) "OK"
    ["statusCode":"Nyholm\Psr7\Response":private]=>
    int(200)
    ["headers":"Nyholm\Psr7\Response":private]=>
    array(14) {
      ["x-frame-options"]=>
      array(1) {
        [0]=>
        string(10) "SAMEORIGIN"
      }
      ["x-content-type-options"]=>
      array(1) {
        [0]=>
        string(7) "nosniff"
      }
      ["content-encoding"]=>
      array(1) {
        [0]=>
        string(4) "gzip"
      }
      ["strict-transport-security"]=>
      array(1) {
        [0]=>
        string(16) "max-age=31536000"
      }
      ["expires"]=>
      array(1) {
        [0]=>
        string(29) "Tue, 27 Apr 1971 19:44:06 GMT"
      }
      ["content-type"]=>
      array(1) {
        [0]=>
        string(24) "text/html; charset=utf-8"
      }
      ["cache-control"]=>
      array(1) {
        [0]=>
        string(8) "no-cache"
      }
      ["date"]=>
      array(1) {
        [0]=>
        string(29) "Wed, 06 May 2020 02:53:08 GMT"
      }
      ["server"]=>
      array(1) {
        [0]=>
        string(22) "YouTube Frontend Proxy"
      }
      ["x-xss-protection"]=>
      array(1) {
        [0]=>
        string(1) "0"
      }
      ["alt-svc"]=>
      array(1) {
        [0]=>
        string(169) "h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43""
      }
      ["transfer-encoding"]=>
      array(1) {
        [0]=>
        string(7) "chunked"
      }
      ["Content-Location"]=>
      array(1) {
        [0]=>
        string(43) "https://www.youtube.com/watch?v=0YVwtb8pZZY"
      }
      ["X-Request-Time"]=>
      array(1) {
        [0]=>
        string(8) "1.081 ms"
      }
    }
    ["headerNames":"Nyholm\Psr7\Response":private]=>
    array(14) {
      ["x-frame-options"]=>
      string(15) "x-frame-options"
      ["x-content-type-options"]=>
      string(22) "x-content-type-options"
      ["content-encoding"]=>
      string(16) "content-encoding"
      ["strict-transport-security"]=>
      string(25) "strict-transport-security"
      ["expires"]=>
      string(7) "expires"
      ["content-type"]=>
      string(12) "content-type"
      ["cache-control"]=>
      string(13) "cache-control"
      ["date"]=>
      string(4) "date"
      ["server"]=>
      string(6) "server"
      ["x-xss-protection"]=>
      string(16) "x-xss-protection"
      ["alt-svc"]=>
      string(7) "alt-svc"
      ["transfer-encoding"]=>
      string(17) "transfer-encoding"
      ["content-location"]=>
      string(16) "Content-Location"
      ["x-request-time"]=>
      string(14) "X-Request-Time"
    }
    ["protocol":"Nyholm\Psr7\Response":private]=>
    string(3) "1.1"
    ["stream":"Nyholm\Psr7\Response":private]=>
    object(Nyholm\Psr7\Stream)#154 (6) {
      ["stream":"Nyholm\Psr7\Stream":private]=>
      resource(288) of type (stream)
      ["seekable":"Nyholm\Psr7\Stream":private]=>
      bool(true)
      ["readable":"Nyholm\Psr7\Stream":private]=>
      bool(true)
      ["writable":"Nyholm\Psr7\Stream":private]=>
      bool(true)
      ["uri":"Nyholm\Psr7\Stream":private]=>
      string(10) "php://temp"
      ["size":"Nyholm\Psr7\Stream":private]=>
      NULL
    }
  }
  ["uri":"Embed\Extractor":private]=>
  object(Nyholm\Psr7\Uri)#153 (7) {
    ["scheme":"Nyholm\Psr7\Uri":private]=>
    string(5) "https"
    ["userInfo":"Nyholm\Psr7\Uri":private]=>
    string(0) ""
    ["host":"Nyholm\Psr7\Uri":private]=>
    string(15) "www.youtube.com"
    ["port":"Nyholm\Psr7\Uri":private]=>
    NULL
    ["path":"Nyholm\Psr7\Uri":private]=>
    string(6) "/watch"
    ["query":"Nyholm\Psr7\Uri":private]=>
    string(13) "v=0YVwtb8pZZY"
    ["fragment":"Nyholm\Psr7\Uri":private]=>
    string(0) ""
  }
  ["crawler":"Embed\Extractor":private]=>
  object(Embed\Http\Crawler)#141 (4) {
    ["requestFactory":"Embed\Http\Crawler":private]=>
    object(Nyholm\Psr7\Factory\Psr17Factory)#148 (0) {
    }
    ["uriFactory":"Embed\Http\Crawler":private]=>
    object(Nyholm\Psr7\Factory\Psr17Factory)#149 (0) {
    }
    ["client":"Embed\Http\Crawler":private]=>
    object(Embed\Http\CurlClient)#145 (2) {
      ["responseFactory":"Embed\Http\CurlClient":private]=>
      object(Nyholm\Psr7\Factory\Psr17Factory)#144 (0) {
      }
      ["settings":"Embed\Http\CurlClient":private]=>
      array(0) {
      }
    }
    ["defaultHeaders":"Embed\Http\Crawler":private]=>
    array(2) {
      ["User-Agent"]=>
      string(82) "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:73.0) Gecko/20100101 Firefox/73.0"
      ["Cache-Control"]=>
      string(9) "max-age=0"
    }
  }
  ["document":"Embed\Extractor":private]=>
  object(Embed\Document)#157 (3) {
    ["extractor":"Embed\Document":private]=>
    *RECURSION*
    ["document":"Embed\Document":private]=>
    object(DOMDocument)#160 (35) {
      ["doctype"]=>
      string(22) "(object value omitted)"
      ["implementation"]=>
      string(22) "(object value omitted)"
      ["documentElement"]=>
      string(22) "(object value omitted)"
      ["actualEncoding"]=>
      NULL
      ["encoding"]=>
      NULL
      ["xmlEncoding"]=>
      NULL
      ["standalone"]=>
      bool(true)
      ["xmlStandalone"]=>
      bool(true)
      ["version"]=>
      NULL
      ["xmlVersion"]=>
      NULL
      ["strictErrorChecking"]=>
      bool(true)
      ["documentURI"]=>
      NULL
      ["config"]=>
      NULL
      ["formatOutput"]=>
      bool(false)
      ["validateOnParse"]=>
      bool(false)
      ["resolveExternals"]=>
      bool(false)
      ["preserveWhiteSpace"]=>
      bool(true)
      ["recover"]=>
      bool(false)
      ["substituteEntities"]=>
      bool(false)
      ["nodeName"]=>
      string(9) "#document"
      ["nodeValue"]=>
      NULL
      ["nodeType"]=>
      int(13)
      ["parentNode"]=>
      NULL
      ["childNodes"]=>
      string(22) "(object value omitted)"
      ["firstChild"]=>
      string(22) "(object value omitted)"
      ["lastChild"]=>
      string(22) "(object value omitted)"
      ["previousSibling"]=>
      NULL
      ["nextSibling"]=>
      NULL
      ["attributes"]=>
      NULL
      ["ownerDocument"]=>
      NULL
      ["namespaceURI"]=>
      NULL
      ["prefix"]=>
      string(0) ""
      ["localName"]=>
      NULL
      ["baseURI"]=>
      NULL
      ["textContent"]=>
      string(436556) "var ytcfg = {d: function() {return (window.yt && yt.config_) || ytcfg.data_ || (ytcfg.data_ = {});},get: function(k, o) {return (k in ytcfg.d()) ? ytcfg.d()[k] : o;},set: function() {var a = arguments;if (a.length > 1) {ytcfg.d()[a[0]] = a[1];} else {for (var k in a[0]) {ytcfg.d()[k] = a[0][k];}}}};window.ytcfg.set('EMERGENCY_BASE_URL', "\/error_204?t=jserror\u0026level=ERROR\u0026client.version=2.20200505.03.00\u0026client.name=1");var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}};$jscomp.arrayIterator=function(a){return{next:$jscomp.arrayIteratorImpl(a)}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};$jscomp.getGlobal=function(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.SymbolClass=function(a,b){this.$jscomp$symbol$id_=a;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:b})};$jscomp.SymbolClass.prototype.toString=function(){return this.$jscomp$symbol$id_};
$jscomp.Symbol=function(){function a(c){if(this instanceof a)throw new TypeError("Symbol is not a constructor");return new $jscomp.SymbolClass($jscomp.SYMBOL_PREFIX+(c||"")+"_"+b++,c)}var b=0;return a}();.....
      var meta = document.createElement('meta');
      meta.name = 'referrer';
      meta.content = 'origin-when-cross-origin';
      document.getElementsByTagName('head')[0].appendChild(meta);
  if (window.ytcsi) {window.ytcsi.info("st", 981, '');}"
    }
    ["xpath":"Embed\Document":private]=>
    object(DOMXPath)#159 (1) {
      ["document"]=>
      string(22) "(object value omitted)"
    }
  }
  ["oembed":"Embed\Extractor":private]=>
  object(Embed\OEmbed)#158 (1) {
    ["endpoint":"Embed\OEmbed":private]=>
    uninitialized(?Psr\Http\Message\UriInterface)
    ["extractor":"Embed\OEmbed":private]=>
    *RECURSION*
    ["data":"Embed\OEmbed":private]=>
    uninitialized(array)
  }
  ["linkedData":"Embed\Extractor":private]=>
  object(Embed\LinkedData)#164 (1) {
    ["document":"Embed\LinkedData":private]=>
    uninitialized(?ML\JsonLD\DocumentInterface)
    ["extractor":"Embed\LinkedData":private]=>
    *RECURSION*
    ["data":"Embed\LinkedData":private]=>
    uninitialized(array)
  }
  ["metas":"Embed\Extractor":private]=>
  object(Embed\Metas)#163 (1) {
    ["extractor":"Embed\Metas":private]=>
    *RECURSION*
    ["data":"Embed\Metas":private]=>
    uninitialized(array)
  }
  ["settings":"Embed\Extractor":private]=>
  array(0) {
  }
  ["customDetectors":"Embed\Extractor":private]=>
  array(0) {
  }
  ["authorName":protected]=>
  object(Embed\Detectors\AuthorName)#162 (1) {
    ["extractor":protected]=>
    *RECURSION*
    ["cache":"Embed\Detectors\Detector":private]=>
    uninitialized(array)
  }
  ["authorUrl":protected]=>
  object(Embed\Detectors\AuthorUrl)#161 (1) {
    ["extractor":protected]=>
    *RECURSION*
    ["cache":"Embed\Detectors\Detector":private]=>
    uninitialized(array)
  }
  ["cms":protected]=>
  object(Embed\Detectors\Cms)#165 (1) {
    ["extractor":protected]=>
    *RECURSION*
    ["cache":"Embed\Detectors\Detector":private]=>
    uninitialized(array)
  }
  ["code":protected]=>
  object(Embed\Detectors\Code)#166 (1) {
    ["extractor":protected]=>
    *RECURSION*
    ["cache":"Embed\Detectors\Detector":private]=>
    uninitialized(array)
  }
  ["description":protected]=>
  object(Embed\Detectors\Description)#167 (1) {
    ["extractor":protected]=>
    *RECURSION*
    ["cache":"Embed\Detectors\Detector":private]=>
    uninitialized(array)
  }
  ["favicon":protected]=>
  object(Embed\Detectors\Favicon)#168 (1) {
    ["extractor":protected]=>
    *RECURSION*
    ["cache":"Embed\Detectors\Detector":private]=>
    uninitialized(array)
  }
  ["feeds":protected]=>
  object(Embed\Adapters\Youtube\Detectors\Feeds)#182 (1) {
    ["extractor":protected]=>
    *RECURSION*
    ["cache":"Embed\Detectors\Detector":private]=>
    uninitialized(array)
  }
  ["icon":protected]=>
  object(Embed\Detectors\Icon)#170 (1) {
    ["extractor":protected]=>
    *RECURSION*
    ["cache":"Embed\Detectors\Detector":private]=>
    uninitialized(array)
  }
  ["image":protected]=>
  object(Embed\Detectors\Image)#171 (1) {
    ["extractor":protected]=>
    *RECURSION*
    ["cache":"Embed\Detectors\Detector":private]=>
    uninitialized(array)
  }
  ["keywords":protected]=>
  object(Embed\Detectors\Keywords)#172 (1) {
    ["extractor":protected]=>
    *RECURSION*
    ["cache":"Embed\Detectors\Detector":private]=>
    uninitialized(array)
  }
  ["language":protected]=>
  object(Embed\Detectors\Language)#173 (1) {
    ["extractor":protected]=>
    *RECURSION*
    ["cache":"Embed\Detectors\Detector":private]=>
    uninitialized(array)
  }
  ["languages":protected]=>
  object(Embed\Detectors\Languages)#174 (1) {
    ["extractor":protected]=>
    *RECURSION*
    ["cache":"Embed\Detectors\Detector":private]=>
    uninitialized(array)
  }
  ["license":protected]=>
  object(Embed\Detectors\License)#175 (1) {
    ["extractor":protected]=>
    *RECURSION*
    ["cache":"Embed\Detectors\Detector":private]=>
    uninitialized(array)
  }
  ["providerName":protected]=>
  object(Embed\Detectors\ProviderName)#176 (1) {
    ["extractor":protected]=>
    *RECURSION*
    ["cache":"Embed\Detectors\Detector":private]=>
    uninitialized(array)
  }
  ["providerUrl":protected]=>
  object(Embed\Detectors\ProviderUrl)#177 (1) {
    ["extractor":protected]=>
    *RECURSION*
    ["cache":"Embed\Detectors\Detector":private]=>
    uninitialized(array)
  }
oscarotero commented 4 years ago

I don't understand, it seems to work fine. What's the problem?

byndstd commented 4 years ago

I don't understand, it seems to work fine. What's the problem?

$info->image doesn't return image path that what $info->image return

object(Nyholm\Psr7\Uri)#187 (7) {
["scheme":"Nyholm\Psr7\Uri":private]=>
string(5) "https"
["userInfo":"Nyholm\Psr7\Uri":private]=>
string(0) ""
["host":"Nyholm\Psr7\Uri":private]=>
string(11) "i.ytimg.com"
["port":"Nyholm\Psr7\Uri":private]=>
NULL
["path":"Nyholm\Psr7\Uri":private]=>
string(29) "/vi/-COiNtJBr8I/hqdefault.jpg"
["query":"Nyholm\Psr7\Uri":private]=>
string(0) ""
["fragment":"Nyholm\Psr7\Uri":private]=>
string(0) ""
}
oscarotero commented 4 years ago

The url values (image, url, authorUrl...) are returned in PSR-7 UriInterface, so you have methods like $url->getPath(), $url->getHost(), etc.

This interface includes the __toString() magic method, so If you want to convert this value to a string, just do $imgString = (string) $info->image.

byndstd commented 4 years ago

Yes Thank you so much it's working Thank you again