如何通过爱语飞飞,推送通知消息到微信?
PHP示例代码
首先配置您申请到的TOKEN令牌:define('IYUU_TOKEN', '');
方法一、http发送GET请求:file_get_contents()函数
file_get_contents('http://iyuu.cn/'. IYUU_TOKEN .'.send?text='.urlencode('这是第281封信!'));
方法二、https发送GET请求:file_get_contents()函数
$sslConfig = array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
$urlparam = array(
'text' => $text,
'desp' => $desp
);
$apiUrl = "https://iyuu.cn/". IYUU_TOKEN ."?".join("&",$urlparam);
$json = file_get_contents($apiUrl,false,stream_context_create($sslConfig));
方法三、https发送POST请求:file_get_contents()函数
$postdata = http_build_query(
array(
'text' => $text,
'desp' => $desp
)
);
$opts = array('http' =>array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
),
// 解决SSL证书验证失败的问题
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
)
);
$context = stream_context_create($opts);
$result = file_get_contents('https://iyuu.cn/'. IYUU_TOKEN .'.send', false, $context);
方法四、使用curl方法
已封装好的类,下载后解压。点此下载FF.zip
使用方法:
1、打开FF.php
,配置您申请到的TOKEN令牌。
2、在调用的地方:
$text = "这是标题";
$desp = "这是内容";
//GET请求
FF::send($text, $desp);
//POST请求
FF::send($text, $desp, false);