-
-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Youtube with https #417
Comments
I’ve encountered this too, admittedly only over the last couple of days. Is there any reason why some providers use HTTP instead of HTTPS? PR: #418 |
Okay so I've done some digging and found the likely issue. There are two ways used by Embed to determine the correct embed-endpoint of a given provider. First it tries to visit the video URL itself and see if there are any
Note that youtube itself is providing an incorrect protocol in it's uris (http instead of https)! Problem number one found! Okay, I thought, so YouTube is messing up... But why is Embed even trying these link tags when it has preconfigured providers (Youtube, Vimeo etc) that have been designed to do this as indicated here: https://github.com/oscarotero/Embed/blob/master/src/resources/oembed.php#L932. The answer to that can be found here: https://github.com/oscarotero/Embed/blob/master/src/OEmbed.php#L56-L60. As you can see there, the So summarizing:
Now to the actual fix, that's a tougher nut to crack. Here are the options as I see them, with my opinion added:
In the meantime my company can't afford to break embedded videos so I will work with a fork until the package author makes a decision on this. Hopes this helps others that are trying to debug this. |
Ok, I see. Thanks for the valuable info @cleentfaar I'm going to wait for Youtube. Changing the priority of the detectors may fix this issue but open others. The philosophy of this library is rely first in the data provided by the site (that can change anytime) and only use the pre-configured data as the last resort, because it can become deprecated anytime. |
@oscarotero not sure I understand what you mean, the demo you link to doesnt work either? |
ok, but thats not what happening in my code at the moment, it just returns null, what should I change to use that opengraph?
are you suggesting doing something with |
Sorry, I don't understand. Doesn't this code work for you? $info = $embed->get($url);
$embedHtml = $info->code; I mean, you don't have to get the different apis directly (oembed, meta, etc). Embed library does it automatically for you, as you can see in the example: https://github.com/oscarotero/Embed#usage |
@oscarotero to add some further clarification: This works fine:
This fails:
with (json output):
Following the url directly in the browser: http://www.youtube.com/oembed?format=json&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DsRy8aLzZRyA performs a 301 redirect. I wonder if the underlying code is not following redirects? |
I tried to fix this in #419 |
The function |
Sorry that should have been |
Ok. This is because this library not only use oEmbed API to get the data, but also html meta tags, linked data, etc. You shouldn't use the oEmbed class directly, but the |
Your lib is used in Bolts CMS (at least 3.x version) to embed Youtube video.
Since ?? weeks/months, it doesn't work anymore with the following error :
Can we access Youtube URL with https :
https://www.youtube.com/oembed
(I made the correction in my vendors and it's OK)
I can make a PR if you want.
Tahnks
The text was updated successfully, but these errors were encountered: