I want to allow user creating oEmbed content to my website. There is a lot of information how to implement it but none about creating a enpoint.
Quick question: is there some ready php code samples for
creating
(returning) oEmbed response for third party websites?If no, how to create it? Ex youtube link looks like this:
http://www.youtube.com/oembed?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DiwGFalTRHDA
and the response is :
{ "html": "<iframe width=\"459\" height=\"344\" src=\"https://www.youtube.com/embed/iwGFalTRHDA?feature=oembed\" frameborder=\"0\" allowfullscreen></iframe>", "thumbnail_height": 360, "thumbnail_width": 480, "provider_name": "YouTube", "author_url": "https://www.youtube.com/user/KamoKatt", "thumbnail_url": "https://i.ytimg.com/vi/iwGFalTRHDA/hqdefault.jpg", "author_name": "KamoKatt", "provider_url": "https://www.youtube.com/", "type": "video", "version": "1.0", "width": 459, "title": "Trololo", "height": 344 }
My question is: how they know which video it is? They are using regexp to parse
videoID
?What is 'best practice' for this kind of request? Should it be created as Controller, Service, Provider or how?
Finally I have created it like this:
services.yml
parameters.yml
next in the controller:
you call it like this: http://project.local/oembed?url=http://project.local/place-marker/4/show