龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

自己写的飞信接口,支持crontab,免费分享给大家

时间:2014-07-22 14:51来源: 作者: 点击:
分享到:
之前看到有人发布的飞信接口,醉翁之意不在酒, 用来卖钱的,BS之。。。br / br / 自己抽空写了一个,拿出来跟大家分享,写的不好的地方大家可以提出来,共同探讨学习。img src=http
之前看到有人发布的飞信接口,醉翁之意不在酒, 用来卖钱的,BS之。。。

自己抽空写了一个,拿出来跟大家分享,写的不好的地方大家可以提出来,共同探讨学习。

要求:必须是移动用户,其次需要互为飞信好友才行,不管怎么玩游戏,游戏规则是不能违背的哈。

=============================================================

项目说明如下:
index.php        =>    在线发送飞信的入口页
demo.php        =>    项目演示页,初次使用建议使用demo.php测试下程序是否运行正常
cron.php        =>    用于定时发送一些信息给飞信好友的脚本
weather_php.bat        =>    自己用记事本打开看下里面的注释吧,配合cron.php使用
weather_php.vbs        =>    vbs脚本,配合上面的weather_php.bat批处理使用,主要作用是让批处理执行的时候隐藏command窗口
class.fetion.php    =>    这个就不多说了,核心文件,就靠他了。

其他:
要让cron.php定时执行的话Windows用户当然要使用“计划任务”啦,自己添加一个任务即可,定期运行weather_php.vbs

如果是Linux用户,可以使用/etc/crontab    然后自己写个shell脚本就行啦,这个大家自己去研究吧~


相关东东都在压缩包里面了,readme.txt里我也备注了使用说明~

================================================================
在线演示地址:  http://feixin.cxxmv.com:81

sendmsg.php页面最后第二行修改成:echo Fetion::sendMsg($fid, $msgContent); 前面少了个echo,否则看不到发送结果。 感谢“ 黄勃SEEVIA”反馈

<?php
set_time_limit(0);
date_default_timezone_set('PRC');
include 'class.fetion.php';

#============= CURL获取第三方数据,请自行修改[说白了,就是采集数据,小偷程序啦~!] =============
$ch = curl_init('http://www.weather.com');
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
$result = curl_exec($ch);
curl_close($ch);
if(!$result) {
	exit;
}
preg_match('/<a href="tqyb.html"  target="_blank">(.*)<\/a><\/div><script/is', $result, $todayWeather);
$weatherReport = trim($todayWeather[1]);
$weatherReport = 'xxx天气预报:'.$weatherReport;
unset($todayWeather, $result);


#============= 账号变量相关配置 =============
$fetion_account = '15951112345';//飞信帐号
$fetion_password = '123456';	//飞信密码
$mobileArr = array('15951112345', '13773212345', '13962212345');	//收件人


#============= 以下内容无需需改,如有需要,请根据实际情况进行修改 =============
$str = '';
foreach($mobileArr as $k => $v) {
	$retryInit = 1;
	//重试三次
	while($retryInit <= 3) {
		new Fetion ($fetion_account, $fetion_password);
		$sendStatus = Fetion::sendMsg($v, $weatherReport);
		if(strrpos($sendStatus, '失败') === false) {
			break;	
		}
		$retryInit++;
	} 

	$str .= '发送号码:'.$v."\n"; 
	$str .= '重试次数:'.$retryInit."\n"; 
	$str .= '发送状态:'.strip_tags($sendStatus)."\n"; 
	$str .= '发送时间:'.date('Y-m-d H:i:s')."\n\n"; 
	
}
$str .= $weatherReport."\n";
$str .= "===================================== ".date('Y-m-d')." =====================================\n\n\n";
$fp = fopen('send_log.txt', 'a+');
fwrite($fp, $str);
fclose($fp);
//echo $sendStatus;
unset($str, $weatherReport);
?>

3. [图片] web界面    

精彩图集

赞助商链接