douba1617 2015-04-25 10:37
浏览 37

如何youtube缩略图链接替换为站点链接

I have problem youtube video and thumbnails block in our country and I want to run youtube api for getting these data , but problem is thumbnails links show like these link

enter image description here

I want to its show through my site link with my server like

https://img.example.com/vi/T0Jqdjbed40/default.jpg

I try to replace url with string replace function but its not work please tell me how to run through my site link like some site show like playit , vube.pk , flix

  • 写回答

1条回答 默认 最新

  • douzhou7037 2015-04-25 10:41
    关注

    As a purely theoretical thing, you can replace sections of a string using the str_replace function:

    str_replace(
        "https://i.ytimg.com/vi/T0Jqdjbed40/default.jpg",
        "://i.ytimg.com", "://img.example.com");
    

    This will keep the http:// or https:// protocol in place.


    For your use case, again purely theoretically, you would want to download the resource yourself, and then provide it to the end user. To get the data using file_get_contents for example:

    $data = file_get_contents('http://www.example.com/');
    

    You culd then potentially embed the image data directly into the page itself - see this SO question: Can I embed a .png image into an html page?

    You should probably check youtube's terms of service before attempting anything...

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?