hadsky论坛熊掌号改造教程

打开模板里的main.hst文件

在head加入

<link rel="canonical" href="这里写对应的h5域名{$_G['TEMP']['URL']}"/>

<link rel="miphtml" href="这里写对应的mip域名{$_G['TEMP']['URL']}"/>

<script src="//msite.baidu.com/sdk/c.js?appid=熊掌号ID"></script>

没有mip版的可以删除<link rel=”miphtml” href=”这里写对应的mip域名{$_G[‘TEMP’][‘URL’]}”/>

 

然后打开模板里的phpscript文件夹,编辑main.php添加下面这段代码。

$_G['TEMP']['URL'] = $_SERVER['REDIRECT_URL'];

phpscript代码

放在read-1.php里的。

//熊掌号出图获取图片

$imgnum = 0;

$_G['TEMP']['IMGS'] = '';

$imgshtml = array();

$noimglist = 'emotion';

if (preg_match_all('#<img.*?src="(.*?)".*?alt="(.*?)".*?\>#', $readdata['content'], $match)) {

foreach ($match[1] as $key => $value) {

if (!InArray($noimglist, $match[2][$key])) {

if ($imgnum > 2) {

break;

}

$imgshtml[$imgnum] = array('src' => $value);

$imgnum++;

}

}

}

 

$_G['TEMP']['IMGHTML'] = '';

$_G['TEMP']['IMGNUM'] = '';

switch ($imgnum) {

//熊掌号出图1图

case 1 :

case 2 :

$_G['TEMP']['IMGNUM'] = 1;

$_G['TEMP']['IMGXZH'] .= '"https://manye.net/' . $imgshtml[0]['src'] . '"';

break;

//熊掌号出图3图

case 3 :

$_G['TEMP']['IMGNUM'] = 3;

$_G['TEMP']['IMGXZH'] .= '"https://manye.net/' . $imgshtml[0]['src'] . '",';

$_G['TEMP']['IMGXZH'] .= '"https://manye.net/' . $imgshtml[1]['src'] . '",';

$_G['TEMP']['IMGXZH'] .= '"https://manye.net/' . $imgshtml[2]['src'] . '"';

break;

}

 

hst代码

放在read-1.hst里的

<script type="application/ld+json">

{

"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",

"@id": "{ReWriteURL('read','id={$readdata['id']}&page=1')}",

"appid": "熊掌号id",

"title": "{$readdata['title']}",

"images": [

{$_G['TEMP']['IMGXZH']}

],

"pubDate": "{date('Y-m-d',$readdata['posttime'])}T{date('H:m:s',$readdata['posttime'])}"

}

</script>

出图截图演示:

hadsky论坛熊掌号改造教程

文章地址:漫夜 » hadsky论坛熊掌号改造教程
漫夜网QQ群
扫描二维码加入QQ群,一起在线交流!
1400+人已加过群
分享到:
赞(0) 打赏

网站不错赶快打赏吧!

支付宝扫一扫打赏

微信扫一扫打赏