検索
ホームページphp教程PHP源码PHP飞信通知天气预报_API版

/***************************************************************************/
/******************* PHP飞信通知天气预报_API版 *******************************/
/*************************** 2011-12-5 ************************************/
/**************************作者:xiaogg*************************************/
/***************************版本:2.11**************************************/
/*********************http://www.bitefu.net********************************/
header("content-Type: text/html; charset=utf-8");
function curl_file_get_contents($durl){
if(function_exists('curl_setopt')){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $durl);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_USERAGENT, _USERAGENT_);
curl_setopt($ch, CURLOPT_REFERER,_REFERER_);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$r = curl_exec($ch);
curl_close($ch);
}else if(function_exists('file_get_contents')){
$r=file_get_contents($durl);
}else if(function_exists('file')){
$r=file($durl);$r = implode('', $r);
}else{
$r="获取内容失败";
}
return $r;
}
//删除空格
function wtrimall($str,$type=0)
{
$str= str_replace(" ","*-*",$str);
$str= str_replace(" ","*-*",$str);
$str= str_replace("\t","*-*",$str);
$str_s= str_replace("\n","*-*",$str);
$str= str_replace("*-*","",$str_s);
if($type==1)return $str_s;else return $str;
}
//对数组进行键值排序
function wchangearray($str)
{
return array_values(array_filter($str));
}
function wtext($city,$weather_txt="weahter.txt")
{
$date=date("Y-m-d");$arr=array();$arr['date']=$date;
if(!file_exists($weather_txt)){file_put_contents($weather_txt,serialize($arr));}
$old=unserialize(file_get_contents($weather_txt));
if($old['date']!=$date){file_put_contents($weather_txt,serialize($arr));}
if($old[$city] && strlen($old[$city])>30){return $old[$city];}else{
switch($city)
{
case "sjz": $url = 'http://www.weather.com.cn/weather/101090101.shtml';$text="石家庄";break;
case "yt": $url = 'http://www.weather.com.cn/weather/101090508.shtml';$text="玉田";break;
}
$lines_string = curl_file_get_contents($url);
$lines_string = explode("','',$lines_string[1]),str_replace('2-->','',$lines_string[2]),str_replace('3-->','',$lines_string_3[0]));
for($i=0;$i< count($lines_array); $i ++)
{
$nowarray=strip_tags($lines_array[$i]);
$datearray=explode("日",$nowarray);$nowdata=wtrimall($datearray[0]);//获取日期
$weather=explode("白天",$nowarray);$weather=explode("夜间",$weather[1]);
$weather_bai=wtrimall(str_replace("高温 ","",$weather[0]));$weather_bai=str_replace("℃","度",$weather_bai);//白天天气
$weather_ye=wtrimall(str_replace("低温 ","",$weather[1]));$weather_ye=str_replace("℃","度",$weather_ye);//夜间天气
$baiarr=wchangearray(explode("\r",$weather_bai));$yearr=wchangearray(explode("\r",$weather_ye));
$wtext[$i]=trim($nowdata)."日";
if($baiarr[0]==$yearr[0]){$wtext[$i].=$baiarr[0];}else{$wtext[$i].=$baiarr[0]."转".$yearr[0];}//将天气添加到返回值里
$wtext[$i].=$baiarr[1]."到".$yearr[1];//将气温添加到返回值里
if($baiarr[2]==$yearr[2]){$wtext[$i].=$baiarr[2];}else{$wtext[$i].=str_replace("风","",$baiarr[2]."转".$yearr[2]);$wtext[$i].="风";}//将风向添加到返回值里
if($baiarr[3]!="微风"){$wtext[$i].=$baiarr[3];}//将风力添加到返回值里
}
$new=$text.implode("",$wtext);
if(strlen($new)<30){$new=wtext($city);};
$newarr=array($city=>$new);
file_put_contents($weather_txt,serialize(array_unique(array_merge($old,$newarr))));
return $new;
}
}
//配置开始
$phone_num = "150******";//在这修改为您的手机号码;
$password = "******" ;//在这修改为您的飞信密码
$phone="150******|yt;134******|yt;151******|sjz;150******|sjz";//在这修改为要发送的电话号码,多个发送用,分开。注:必须是您的飞信好友
//配置结束

$tophone=explode(";",$phone);
//发送短信
for($i=0;$i $sys=explode("|",$tophone[$i]);
$url="http://www.bitefu.net/fetion/?";
$url.="phone=".$phone_num."&pwd=".$password."&to=".$sys[0]."&u=1&msg=".wtext($sys[1]);//&u=1这个参数是在发送的内容出现乱码时加上的,如果存在乱码问题可以去掉这个参数
file_get_contents($url);
}if($i==count($tophone)){sleep(100);
?>

声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

AtomエディタMac版ダウンロード

AtomエディタMac版ダウンロード

最も人気のあるオープンソースエディター

MantisBT

MantisBT

Mantis は、製品の欠陥追跡を支援するために設計された、導入が簡単な Web ベースの欠陥追跡ツールです。 PHP、MySQL、Web サーバーが必要です。デモおよびホスティング サービスをチェックしてください。

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強力な PHP 統合開発環境

EditPlus 中国語クラック版

EditPlus 中国語クラック版

サイズが小さく、構文の強調表示、コード プロンプト機能はサポートされていません

SecLists

SecLists

SecLists は、セキュリティ テスターの究極の相棒です。これは、セキュリティ評価中に頻繁に使用されるさまざまな種類のリストを 1 か所にまとめたものです。 SecLists は、セキュリティ テスターが必要とする可能性のあるすべてのリストを便利に提供することで、セキュリティ テストをより効率的かつ生産的にするのに役立ちます。リストの種類には、ユーザー名、パスワード、URL、ファジング ペイロード、機密データ パターン、Web シェルなどが含まれます。テスターはこのリポジトリを新しいテスト マシンにプルするだけで、必要なあらゆる種類のリストにアクセスできるようになります。