Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何检查和更改链接?_Php_Html_Scripting_Tumblr_Ifttt - Fatal编程技术网

Php 如何检查和更改链接?

Php 如何检查和更改链接?,php,html,scripting,tumblr,ifttt,Php,Html,Scripting,Tumblr,Ifttt,我在一个自动化的Tumblr博客上工作,注意到你不能将Twitch流作为视频帖子发布,但是当你嵌入它们时你可以 将会有多个用户,并且它将不断扩展,因此我正在尝试在IFTTT中自动化脚本,但是,我没有太多的脚本知识,并尝试完成这项工作。。。没有成功 问题是: 这一切都从内容链接开始,这真的可以是任何平台。但是,Tumblr不支持的所有平台都需要不同的嵌入 所以我想要的是一个脚本(不需要脚本,只需要帮助),它可以检测链接来自哪个平台,并根据发现的内容选择路径 基本上,这是一个脚本,用于检查它是否是t

我在一个自动化的Tumblr博客上工作,注意到你不能将Twitch流作为视频帖子发布,但是当你嵌入它们时你可以

将会有多个用户,并且它将不断扩展,因此我正在尝试在IFTTT中自动化脚本,但是,我没有太多的脚本知识,并尝试完成这项工作。。。没有成功

问题是:

这一切都从内容链接开始,这真的可以是任何平台。但是,Tumblr不支持的所有平台都需要不同的嵌入

所以我想要的是一个脚本(不需要脚本,只需要帮助),它可以检测链接来自哪个平台,并根据发现的内容选择路径

基本上,这是一个脚本,用于检查它是否是twitch、runa、youtube runb,等等

如果输入包含“Twitch”运行

<html>
  <body>
    <div id="twitch-embed"></div>
    <script src="https://embed.twitch.tv/embed/v1.js"></script>
    <script type="text/javascript">
      new Twitch.Embed("twitch-embed", {
        width: 854,
        height: 480,
        channel: "{channel Name}"
      });
    </script>
  </body>
</html>
<script type="text/html" id="Video URL here">

新建Twitch.Embed(“Twitch嵌入”{
宽度:854,
身高:480,
频道:{频道名称}
});
如果YouTube

<html>
  <body>
    <div id="twitch-embed"></div>
    <script src="https://embed.twitch.tv/embed/v1.js"></script>
    <script type="text/javascript">
      new Twitch.Embed("twitch-embed", {
        width: 854,
        height: 480,
        channel: "{channel Name}"
      });
    </script>
  </body>
</html>
<script type="text/html" id="Video URL here">

如何创建这些支票


(我知道这个问题很愚蠢,而且可能很简单,但我对脚本编写不是很在行)

您可以获取URL字符串并对照每个关键字检查它,以确定它是否存在:

var urlString = "https://www.twitch.tv/Reco_Mouse";

if(urlString.indexOf("twitch.tv") !== -1) {

  //First, dynamically include the Twitch script tag on the page

  new Twitch.Embed("twitch-embed", {
    width: 854,
    height: 480,
    channel: "{channel Name}"
  });
  break;

} else if(urlString.indexOf("youtube.com") !== -1) {

  //Apply necessary steps for YouTube videos

} else if(urlString.indexOf("anothervideotype.com") !== -1) {

  ... //Apply necessary steps for another video type

}

谢谢,伙计,这真的很有帮助!