Comments (26)
Hi.
I don't see any problem. It works fine in my computer and in the online demo: http://oscarotero.com/embed2/demo/index.php?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DkUylIQy-IgI
Maybe your computer has some requirements missing? (curl extension or any configuration that avoid create https requests?)
from embed.
It was working perfectly earlier, but now It's giving false don't know why ? But when I try to fetch vimeo,facebook,vine embed It does fetch. It's giving false for instagram and vimeo.
And yes curl is installed.
from embed.
Can you do a var_dump
of $this->resut
here?, so we can see the info about the curl request.
from embed.
I got the following output by doing var_dump
array(26) { ["url"]=> string(43) "https://www.youtube.com/watch?v=kUylIQy-IgI" ["content_type"]=> string(24) "text/html; charset=utf-8" ["http_code"]=> int(429) ["header_size"]=> int(465) ["request_size"]=> int(193) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(0.180564) ["namelookup_time"]=> float(0.004171) ["connect_time"]=> float(0.012106) ["pretransfer_time"]=> float(0.030642) ["size_upload"]=> float(0) ["size_download"]=> float(33043) ["speed_download"]=> float(182998) ["speed_upload"]=> float(0) ["download_content_length"]=> float(-1) ["upload_content_length"]=> float(0) ["starttransfer_time"]=> float(0.172199) ["redirect_time"]=> float(0) ["redirect_url"]=> string(0) "" ["primary_ip"]=> string(14) "173.194.33.129" ["certinfo"]=> array(0) { } ["primary_port"]=> int(443) ["local_ip"]=> string(13) "172.31.42.173" ["local_port"]=> int(42737) }
from embed.
I see the http code result is 429, that means "Too many requests" (https://en.wikipedia.org/wiki/List_of_HTTP_status_codes)
Maybe you're executing to many requests to youtube and it blocks you temporary.
from embed.
Is there any solution for that ? And Instagram was not working, but now it's working fine.
Thanks for your help.
from embed.
I guess this depends of each service. Youtube and instagram may have a limited number of request in a time interval. Maybe executing the requests using different ips, but this is something out of the scope of this library.
from embed.
Thanks for your help.
from embed.
I too get false for youtube. All other works fine. Youtube works fine with localhost, But not in server. How to debug?
from embed.
@abelkbil do a var_dump of $this->resut here?, so we can see the info about the curl request.
from embed.
The latest version throws an exception instead simply returns true
, so you can see why the curl request failed.
from embed.
I have changed my IP and have taken another ec2 instance with different ip but still it gives the same error even It's my first call to YouTube with this IP, any solution ?
from embed.
With updated library, It throws this error.
Fatal error: Uncaught exception 'Embed\Exceptions\InvalidUrlException' with message 'The url 'https://www.youtube.com/watch?v=PP1xn5wHtxE' returns the http code '429'' in /var/www/newsroom/public_html/app/inc/class/lib/Embed1/src/Embed.php:21 Stack trace: #0 /var/www/newsroom/public_html/app/test.php(3): Embed\Embed::create('https://www.you...') #1 {main} thrown in /var/www/newsroom/public_html/app/inc/class/lib/Embed1/src/Embed.php on line 21
from embed.
It's a bit odd. Can you try to change some curl parameters? Maybe the user agent or something like that.
Another aproach is to try to execute the curl request outside of the library:
$connection = curl_init();
curl_setopt_array($connection, [
CURLOPT_RETURNTRANSFER => false,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_URL => 'https://www.youtube.com/watch?v=kUylIQy-IgI',
CURLOPT_MAXREDIRS => 20,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 10,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_ENCODING => '',
CURLOPT_AUTOREFERER => true,
CURLOPT_USERAGENT => 'Embed PHP Library',
CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
]);
$content = curl_exec($connection);
var_dump(curl_getinfo($connection));
from embed.
When I tried curl request outside the library this content was shown.
from embed.
I don't know why this happens, seems like youtube detects the same network, no matter the specific ip.
from embed.
How can it be possible to detect a network instead of IP ? Have any idea ?
from embed.
Google Search blocks IPs, IP ranges, and in some cases, whole ISPs, when a large percent of the traffic entering our networks is abusive.
Maybe your ip is in an ip range that it's blocked. I've googled this and they say the same in all results. I don't think much can be done, except wait for the overload goes away.
from embed.
You have been very supportive all the time, thank you so much for that. :-) I would try it with a totally different IP and let you know..!!
from embed.
Shouldn't we use dedicated methods to fetch thumbnails like https://developers.google.com/youtube/v3/docs/thumbnails ?
from embed.
I'm not using the youtube API because oembed is enought to get all needed data, not only thumbnail but also the author, title, embed code, etc. For example this So I don't see much benefits of using another http request to get the same information.
from embed.
So basically it's not server with installed Embed library requesting for YouTube thumbnail but oembed so why this problem exists?
I mean doing on server: CURL call to YouTube video gives 429 error, but calling http://www.youtube.com/oembed returns nice thumb url.
from embed.
Sorry but I don't understand what you mean.
from embed.
Embed always load the main url in the first place (for example https://www.youtube.com/watch?v=kUylIQy-IgI).
Then, it may execute other http requests depending of the page. For youtube videos, loads the data using the oembed API.
The problem here is youtube returns 429 error in the first call (the main url).
from embed.
So in this case I guess Embed should continue on error from main URL because it can fetch necessary data from other source (oembed). This will work for future services too. Is it possible?
from embed.
Embed doesn't work like that. The main url is loaded because many reasons:
- To be sure the url exists and is valid (it must returns http code 200)
- To resolve possible redirections (for url shorteners like bit.ly or even youtube has its own short url: https://youtu.be/)
- To load data from the html (opengraph, twitter cards, etc)
- A lot of services includes the url of the oembed service in the head. Youtube is one of these services. In the html code there is a link element like
<link rel="alternate" type="application/json+oembed" href="http://www.youtube.com/oembed?format=json&url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DkUylIQy-IgI">
. So this library does not need to include a huge list of oembed endpoits for all possible services (hard to maintain) because they are taken from the html. It just need a small list with the services than does not provide this information in the html.
from embed.
Related Issues (20)
- [Question] Vimeo with "Hide from Vimeo" setting but embeds allowed on specific domains HOT 4
- request's locale change support HOT 2
- psr/http-message V2 support?
- Maximum redirects followed instagram HOT 3
- New release? HOT 1
- Twitter embed->get returns null on production HOT 5
- Twitter extractor will retrieve "/home" instead of a tweet URL HOT 2
- Reddit data is very lacking
- The demo site is offline HOT 3
- It is not work for same domain
- wrong extracted data when fetching image link behind redirect
- Memory leak HOT 8
- Setting user agent for request does not seem to work HOT 2
- Add option to fetch OEmbed only HOT 2
- Unexpected aspect ratio format HOT 3
- CURL error when embedding Twitter HOT 2
- Problem in URLs of MVCs without file extentions in some server...
- Large quantities of embed-cookies-{uid} are being created, but not deleted? HOT 2
- Use maxresdefault instead of hqdefault for YouTube embeds HOT 2
- Twitter.com to X.com migration giving errors HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from embed.