空气中的鱼儿 发表于 2016-10-8 19:06:12

怎么添加第三方资源

本帖最后由 空气中的鱼儿 于 2016-10-23 18:25 编辑

按理说只要 资源站支持飞飞CMS2.7以上版本都可以 增加到采集中去
给大家一个演示

比如资源站 http://zy.ataoju.com/

下载他们提供的飞飞CMS 接口文件

解压后包括了以下文件:
xml_show.html 对应我们程序目录 Public/system/
xml_show_list.html 对应我们程序目录Public/system/
Xml6uzyAction.class.php对应我们程序目录\Lib\Admin\Action
Xml6uzyModel.class.php对应我们程序目录\Lib\Common\Model

首先说简单的方法一般只要是默认得飞飞的接口格式可以使用

打开第三方采集结构压缩包中的 xml_show_list.html
找到他们提供的JS地址
<script language="JavaScript" charset="utf-8" type="text/javascript" src="http://zy.ataoju.com/6uzy.js?{$rand}"></script></div>
然后下载zy.ataoju.com/6uzy.js 这个JS 下载完成后打开这个JS

将 Admin-Xml6uzy-Caijia-替换为 Admin-Xml-Caijia (注意后面为caijia这个是飞飞可以使用的第三方非飞飞程序的接口格式也就是接口为XML 格式)
还有一种接口资源是使用飞飞CMS制作的接口比如我们提供的站外网址接口 是JSON格式的
格式是这样的Admin-Xml6uzy-Feifei替换为Admin-Xml-Feifei (注意后面的Feifei 这个就是飞飞程序提供的JSON格式)


JS中的都全部都要替换 替换完成后 另存这个JS然后上传到你网站更目录

接下来我们在打开 我们网站中的Public/system/xml_show_list.html
然后找到<div id="xmllist" style="display:none">资源JS</div> 在这个DIV中增加你刚才 上传的JS地址 如果是在本地服务器就添加

<div id="xmllist" style="display:none">
<script language="JavaScript" charset="utf-8" type="text/javascript" src="/6uzy.js?{$rand}"></script>这个就是新增加的
<script language="JavaScript" charset="utf-8" type="text/javascript" src="/vip.js?{$rand}"></script>
<script language="JavaScript" charset="utf-8" type="text/javascript" src="http://u.daicuo.com/xml/ff_2.5.js?{$rand}"></script>
</div>


然后基本就OK了 以上方法使用于 部需要修改任何文件提供的格式 符合飞飞CMS2.7以上程序的接口

还有一种就 是 需要修改 程序和文件的接口

文件大致也和上面说的一样 但是
Xml6uzyAction.class.php
Xml6uzyModel.class.php 这两个文件他们有做修改

那么我们就必须修改这两个文件

打开Xml6uzyAction.class.php使用软件DW等不能用记事本 然后 在
头部修改为

namespace Admin\Action;
use Common\Action\BaseAction;
class Xml6uzyActionextends BaseAction{

打开和Xml6uzyModel.class.php 用软件DW等不能用记事本然后头部修改为

namespace Common\Model;
use Think\Model;
class Xml6uzyModel extends Model {

记得不能有空格 两个PHP都需要修改 修改完成后 上传到
Xml6uzyAction.class.php对应我们程序目录\Lib\Admin\Action
Xml6uzyModel.class.php对应我们程序目录\Lib\Common\Model

对应目录上传上去

然后打开下载包中的xml_show.html文件找到function getjumpurl与</script>之间会有两段有?s=Admin-Xml6uzy-的JS代码
第一段为
      if('{$fid}' == '28'){
                return '?s=Admin-Xml6uzy-{*ACTION_NAME}-action-'+$action+'-fid-{$fid}-xmlurl-{$xmlurl}-reurl-{$reurl}-vodids-{$vodids}-play-{$play}-inputer-{$inputer}-cid-'+$cid+'-wd-{$wd}-h-'+$hour;
      }

第二段为
      if('{$fid}' == '28'){
                $('#myform').action = $('#myform').action.replace(/Admin-Xml/, 'Admin-Xml6uzy');
                $('.table .ct a').each(function(){
                        this.href = this.href.replace(/Admin-Xml/, 'Admin-Xml6uzy');
                });
      }

然后我们打开我们程序中的相同位置文件
Public/system/xml_show.html
也是上面相同的位置 将上面说的两段代码第一段修改为{*ACTION_NAME}修改为{$Think.ACTION_NAME}
      else if('{$fid}' == '28'){
                return '?s=Admin-Xml6uzy-{$Think.ACTION_NAME}-action-'+$action+'-fid-{$fid}-xmlurl-{$xmlurl}-reurl-{$reurl}-vodids-{$vodids}-play-{$play}-inputer-{$inputer}-cid-'+$cid+'-wd-{$wd}-h-'+$hour;
      }

增加到我们程序中相关位置下面是已经增加了的

function getjumpurl($action,$cid,$hour){
      if('{$inputer}' == 'vip'){
                return '?s=Admin-Xmlzanpian-{$Think.ACTION_NAME}-action-'+$action+'-fid-{$fid}-xmlurl-{$xmlurl}-reurl-{$reurl}-vodids-{$vodids}-play-{$play}-inputer-{$inputer}-cid-'+$cid+'-wd-{$wd}-h-'+$hour;
      }
      else if('{$inputer}' == 'story'){
                return '?s=Admin-Xmljuqing-{$Think.ACTION_NAME}-action-'+$action+'-fid-{$fid}-xmlurl-{$xmlurl}-reurl-{$reurl}-vodids-{$vodids}-play-{$play}-inputer-{$inputer}-cid-'+$cid+'-wd-{$wd}-h-'+$hour;
      }
      else if('{$fid}' == '28'){
                return '?s=Admin-Xml6uzy-{$Think.ACTION_NAME}-action-'+$action+'-fid-{$fid}-xmlurl-{$xmlurl}-reurl-{$reurl}-vodids-{$vodids}-play-{$play}-inputer-{$inputer}-cid-'+$cid+'-wd-{$wd}-h-'+$hour;
      }

      return '?s=Admin-Xml-{$Think.ACTION_NAME}-action-'+$action+'-fid-{$fid}-xmlurl-{$xmlurl}-reurl-{$reurl}-vodids-{$vodids}-play-{$play}-inputer-{$inputer}-cid-'+$cid+'-wd-{$wd}-h-'+$hour;
}

第二段增加到

$(document).ready(function(){
      $feifeicms.show.table();

      if('{$inputer}' == 'vip'){
                $('#myform').action = $('#myform').action.replace(/Admin-Xml/, 'Admin-Xmlzanpian');
                $('.table .ct a').each(function(){
                        this.href = this.href.replace(/Admin-Xml/, 'Admin-Xmlzanpian');
                });
      }
                else if('{$inputer}' == 'story'){
                $('#myform').action = $('#myform').action.replace(/Admin-Xml/, 'Admin-Xmljuqing');
                $('.table .ct a').each(function(){
                        this.href = this.href.replace(/Admin-Xml/, 'Admin-Xmljuqing');
                });
      }
      else if('{$fid}' == '28'){
                $('#myform').action = $('#myform').action.replace(/Admin-Xml/, 'Admin-Xml6uzy');         
                $('.table .ct a').each(function(){
                        this.href = this.href.replace(/Admin-Xml/, 'Admin-Xml6uzy');
                });
      }

});


上面红色部分是新增加的代码

然后保存我们程序上的这个Public/system/xml_show.html这个文件


最后 打开我们程序上的Public/system/xml_show_list.html文件 将下载到的xml_show_list.html文件中的第三方JS地址增加到 我们程序这个文件中相关位置
我们增加后
<div id="xmltip">资源列表载入中……</div>
<div id="xmllist" style="display:none"><script language="JavaScript" charset="utf-8" type="text/javascript" src="http://zy.ataoju.com/6uzy.js?{$rand}"></script><script language="JavaScript" charset="utf-8" type="text/javascript" src="/vip.js?{$rand}"></script>
<script language="JavaScript" charset="utf-8" type="text/javascript" src="http://u.daicuo.com/xml/ff_2.5.js?{$rand}"></script></div>


然后保存就OK了



thx998 发表于 2016-10-8 19:12:02

好东东啊

xinfuxuanyan 发表于 2016-10-8 20:37:09

好东西

大鱼吃小鱼 发表于 2016-10-14 10:22:20

Namespace declaration statement has to be the very first statement in the script

大鱼吃小鱼 发表于 2016-10-14 10:22:24

Namespace declaration statement has to be the very first statement in the script
页: [1]
查看完整版本: 怎么添加第三方资源