澳门皇冠金沙网站-澳门皇冠844网站

热门关键词: 澳门皇冠金沙网站,澳门皇冠844网站

网站链接查询工具,使用php接入图灵机器人的方

图片 1

<?php教程
header("Content-Type:text/html;charset=gbk");
include_once 'Textclass.php';
$url='111cn.net教程';
if(empty($url) || $url == '')$url = $_GET['message'];
if(preg_match("/(.*?)/$/i",$url)){
 $url=preg_replace("//$/","",$url);
}
$message=__urljudge(eregi_replace("));
$content=array(message=>$message,ip=>$Myip,time=>time());
$text_class->add_line($content);
function _link($url){
 $contents = @file_get_contents("$url");
 if($contents=="Forbidden" || $contents==""){
  $ch = curl_init();
  $timeout = 5;
  curl_setopt ($ch, CURLOPT_URL, "$url");
  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
  curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  $contents = curl_exec($ch);
  curl_close($ch);
 }
 if(empty($contents)){
  exit('<font color=red>cant locaion.</font>');
 }
 preg_match_all("/charset=(.*?)>/is",$contents,$cod);
 if(!empty($cod[1][0])){
  if(preg_match("/utf-8/i",$cod[1][0])){
   $contents=iconv("UTF-8","gbk//TRANSLIT",$contents);
  }
 }
 return $contents;
}
$contents=_link($url);
preg_match_all("/<a href=(.*?)</a>/is",$contents,$link);
foreach($link[0] as $val){
 if(strip_tags($val)){
  preg_match_all("/<a href="(.*?)"/is",$val,$link_url);
  $links[] = $val;
  if(preg_match("/http/i",$link_url[1][0])){
   if(!preg_match("/$message/i",$link_url[1][0])){
    $links_out[] = $link_url[1][0];
    $array[]= '<div class=list_left>'.strip_tags($val).'</div><div class=list_right><a href="'.$link_url[1][0].'">'.$link_url[1][0].'</a></div>';
   }else{
    $array[]= '<div class=list_left>'.strip_tags($val).'</div><div class=list_right><a href="'.$link_url[1][0].'">'.$link_url[1][0].'</a></div>';
   }
  }else{
   if(!preg_match("/^/(.*?)/",$link_url[1][0]))$link_url[1][0]='/'.$link_url[1][0];
   $array[]= '<div class=list_left>'.strip_tags($val).'</div><div class=list_right><a href="'.$url.$link_url[1][0].'">'.$url.$link_url[1][0].'</a></div>';
  }
 }
}

Jpush类

<?php
class Jpush_send{
private $app_key = '618208e20d4ae27510680d5b'; //待发送的应用程序(appKey),只能填多少个。
private $master_secret = 'a7388142bec3b6696996167b'; //主密码
private $url = ""; //推送的地点
public function __construct($app_key=null, $master_secret=null,$url=null) {
if ($app_key) $this->app_key = $app_key;
if ($master_secret) $this->master_secret = $master_secret;
if ($url) $this->url = $url;
}
public function send_pub($receive,$content,$m_type,$m_txt,$m_time){

$m_time = '86400';//离线保留时间

$message="";//存款和储蓄推送状态
$result = $this->push($receive,$content,$m_type,$m_txt,$m_time);
if($result){
$res_arr = json_decode($result, true);
if(isset($res_arr['error'])){ //即便重回了error则证实退步
echo $res_arr['error']['message']; //错误音讯
$error_code=$res_arr['error']['code']; //错误码
switch ($error_code) {
case 200:
$message= '发送成功!';
break;
case 1000:
$message= '失利(系统之中错误)';
break;
case 1001:
$message = '失败(只支持 HTTP Post 方法,不支持 Get 方法)';
break;
case 1002:
$message= '退步(缺乏了必需的参数)';
break;
case 1003:
$message= '失利(参数值违法)';
break;
case 1004:
$message= '失利(验证战败)';
break;
case 1005:
$message= '失利(音讯体太大)';
break;
case 1008:
$message= '退步(appkey参数违规)';
break;
case 1020:
$message= '失败(只支持 HTTPS 请求)';
break;
case 1030:
$message= '战败(内部服务超时)';
break;
default:
$message= '失利(再次来到其余情形,近来不清楚额,请联系开垦人士!)';
break;
}
}else{
$message="发送成功!";
}
}else{
$message='接口调用失利或无响应';
}
echo "<script>alert('推送新闻:{$message}')</script>";
}

public function push($receiver='all',$content='',$m_type='',$m_txt='',$m_time='86400'){
$base64=base64_encode("$this->app_key:$this->master_secret");
$header=array("Authorization:Basic $base64","Content-Type:application/json");
$data = array();
$data['platform'] = 'all'; //目的客户终端手提式有线电话机的平台项目android,ios,winphone
$data['audience'] = $receiver; //目的客户

$data['notification'] = array(
//统一的格局--规范方式
"alert"=>$content,
//安卓自定义
"android"=>array(
"alert"=>$content,
"title"=>"",
"builder_id"=>1,
"extras"=>array("type"=>$m_type, "txt"=>$m_txt)
),
//ios的自定义
"ios"=>array(
"alert"=>$content,
"badge"=>"1",
"sound"=>"default",
"extras"=>array("type"=>$m_type, "txt"=>$m_txt)
)
);

//苹果自定义---为了弹出值方便调测
$data['message'] = array(
"msg_content"=>$content,
"extras"=>array("type"=>$m_type, "txt"=>$m_txt)
);

//附加选项
$data['options'] = array(
"sendno"=>time(),
"time_to_live"=>$m_time, //保存离线时间的秒数默以为一天
"apns_production"=>false, //布尔等级次序 内定 APNS 文告发送蒙受:0开荒蒙受,1生产条件。恐怕传递false和true
);
$param = json_encode($data);
$res = $this->push_curl($param,$header);

if($res){ //获得再次回到值--成功已否前边剖断
return $res;
}else{ //未获得重临值--返回败北
return false;
}
}

//推送的Curl方法
public function push_curl($param="",$header="") {
if (empty($param)) { return false; }
$postUrl = $this->url;
$curlPost = $param;
$ch = curl_init(); //初始化curl
curl_setopt($ch, CURLOPT_URAV4L,$postUrl); //抓取钦定网页
curl_setopt($ch, CURLOPT_HEADER, 0); //设置header
curl_setopt($ch, CURLOPT_RETU奇骏NTRANSFE帕杰罗, 1); //要求结果为字符串且输出到显示器上
curl_setopt($ch, CURLOPT_POST, 1); //post提交方式
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
curl_setopt($ch, CURLOPT_HTTPHEADE牧马人,$header); // 增添 HTTP Header(头)里的字段
curl_setopt($ch, CURLOPT_SSL_VE奥迪Q5IFYPEETucson, FALSE); // 终止从服务端实行认证
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
$data = curl_exec($ch); //运行curl
curl_close($ch);
return $data;
}
}
?>

 

PushController.class.php

<?php

namespace Plutocontroller;

use CommonControllerBaseController;

class PushController extends BaseController {

public function pushDataAction() {
import("Pluto.controller.Jpush_send"); //引入Jpush_send类文件
$fetion = new Jpush_send();
$receive = 'all';//全部
//$receive = array('alias'=>array('2'),'alias'=>array('1'));//别名
$content = '小编要推送';
$m_type = 'tb';
$m_txt = '891';
$m_time = '600'; //离线保留时间
$res=$fetion->send_pub($receive, $content ,$m_type, $m_txt ,$m_time);
}

}

* *

措施调用:

if(!empty($link)){
 echo "<b>网站:<font color=red>".$url."</font></b><br><br>";
 echo "<div id=list_top><b>共有链接<font color=red>".count($links)."</font>,内链<font color=red>".(count($links)-count($links_out))."</font>,外链<font color=red>".count($links_out)."</font></b><br><br></div>";
echo "<a href="./">重回查询首页</a>";
}else{echo "<br><br>网址:<font color=red>".$url."</font>不可能查询,请改动查询地址!";}
?>
<form method="post" id="shoulu">
 <div class="pxd13">
网址:<input type="text" name="message" class="input_1" id="message">
   <input type="submit"   name="Submity" class="button"  value=" 提交 ">
 </div></form>
<?php
require_once 'Textclass.php';
$history=$text_class->openFile();
sort($history,SORT_DESC);
foreach($history as $k => $v){
 $h[] = $v[0];
}
if($h)$history = array_flip(array_flip($h));
?>
<div id="leftcontent_2"></div>
 <?php if ($history){
  foreach ($history as $val){
   echo "<a href=link.php?message=$val class='urls'>".$val."</a>";
  }
 }else{
  echo "<br><p>暂无记录</p>";
 }
 ?>
 </div>

<div id="wrap"><a href="<{:U('Push/pushData')}>">推送</a></div>

 

先睹为快,在那先给我们看看程序的运行结果:

HTML

地方的多个截图是本身把该形式接入到自家的私有订阅号的截图,感兴趣的话你们也能够上去试试,还应该有哪些好用的智能手机器人接口迎接分享我们共同沟通。

本文由澳门皇冠金沙网站发布于编辑程序,转载请注明出处:网站链接查询工具,使用php接入图灵机器人的方