imgrooot Posted May 2, 2019 Share Posted May 2, 2019 I am looking for a code where I can get a video URL from Youtube, Vimeo, Facebook and convert it to an embedded video to be shown on my site. I found a script that does that. It works fine. The only errors I get are in the inspect element window in the browser. Errors such as this. Failed to load resource: net::ERR_BLOCKED_BY_CLIENT googleads.g.doubleclick.net/pagead/id:1 Failed to load resource: net::ERR_BLOCKED_BY_CLIENT static.doubleclick.net/instream/ad_status.js:1 This is the function to generate the embedded videos. Do the above errors matter if the videos show up and play fine? function generateVideoEmbedUrl($url){ //This is a general function for generating an embed link of an FB/Vimeo/Youtube Video. $finalUrl = ''; if(strpos($url, 'facebook.com/') !== false) { //it is FB video $finalUrl.='https://www.facebook.com/plugins/video.php?href='.rawurlencode($url).'&show_text=1&width=200'; }else if(strpos($url, 'vimeo.com/') !== false) { //it is Vimeo video $videoId = explode("vimeo.com/",$url)[1]; if(strpos($videoId, '&') !== false){ $videoId = explode("&",$videoId)[0]; } $finalUrl.='https://player.vimeo.com/video/'.$videoId; }else if(strpos($url, 'youtube.com/') !== false) { //it is Youtube video $videoId = explode("v=",$url)[1]; if(strpos($videoId, '&') !== false){ $videoId = explode("&",$videoId)[0]; } $finalUrl.='https://www.youtube.com/embed/'.$videoId; }else if(strpos($url, 'youtu.be/') !== false){ //it is Youtube video $videoId = explode("youtu.be/",$url)[1]; if(strpos($videoId, '&') !== false){ $videoId = explode("&",$videoId)[0]; } $finalUrl.='https://www.youtube.com/embed/'.$videoId; }else{ //Enter valid video URL } return $finalUrl; } Quote Link to comment https://forums.phpfreaks.com/topic/308661-is-this-the-best-way-to-generate-a-youtubevimeofb-video-embed-code/ Share on other sites More sharing options...
requinix Posted May 2, 2019 Share Posted May 2, 2019 Do you know what those two errors even mean? Do you know what those domains are? Do you see any particular words in those URLs that might give you a clue? Quote Link to comment https://forums.phpfreaks.com/topic/308661-is-this-the-best-way-to-generate-a-youtubevimeofb-video-embed-code/#findComment-1566411 Share on other sites More sharing options...
imgrooot Posted May 2, 2019 Author Share Posted May 2, 2019 (edited) 47 minutes ago, requinix said: Do you know what those two errors even mean? Do you know what those domains are? Do you see any particular words in those URLs that might give you a clue? I just looked those errors up and they have something to do with AdBlocker extension I have installed on the browser. I disabled the AdBlocker extension on that page and reloaded it. Now all the errors are gone. Which is great news. Edited May 2, 2019 by imgrooot Quote Link to comment https://forums.phpfreaks.com/topic/308661-is-this-the-best-way-to-generate-a-youtubevimeofb-video-embed-code/#findComment-1566413 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.