<?php
/* Copyright 2010 princehaku
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Created on : 2010-11-18
* Author : xiaogg
* Site : http://www.xiaogg.tk http://www.ddung.org
*
* 注意 : 请不要将此脚本用于商业用途..
* 此脚本完全是模拟了一个浏览器让用户自主操作,不存在破解或重打包客户端等行为。
* 此脚本以学习为目的,不涉及任何商业利益。任何企业和个人与此接口有关的商业行为,请与移动公司联系。
* 任何人使用此脚本而造成的不良后果,均由使用者承担,与此脚本的作者没有任何关系。
*/
/*
* 一些关于通讯的说明
*
*===================================================
* 获取cookie
* 传值方式 GET
*---------------------------------------------------
*+http://f.10086.cn/im/login/login.action
*===================================================
*
*
*===================================================
* 登陆
* 传值方式 POST
*---------------------------------------------------
*+http://f.10086.cn/im/login/inputpasssubmit1.action
*-loginstatus 1 1在线2隐身
*-m 手机号码
*-pass 飞信密码
*---------------------------------------------------
*-成功提示 正在为您
*+http://f.10086.cn/im/index/indexcenter.action?t=6629642626836875
*===================================================
*
*
*===================================================
* 发送消息
* 传值方式 POST
*---------------------------------------------------
*+http://f.10086.cn/im/chat/sendMsg.action?touserid={飞信id}
*-msg 消息正文
*-touchTextLength 可选
*-touchTitle 可选
*===================================================
*
*
*===================================================
* 搜索
* 传值方式 POST
*---------------------------------------------------
*http://f.10086.cn/im/index/searchOtherInfoList.action?t=6833743967809875
*-searchText 正文 可选
*===================================================
*
*===================================================
* 退出登录
* 传值方式 GET
*---------------------------------------------------
*http://f.10086.cn/im/index/logoutsubmit.action?t=6833743967809875
*===================================================
*/
error_reporting(9);
/**用curl做的联网类
*/
class httpconnector{
private $curl;
/**cookie字符串
*/
private $cookie;
/**get方式下载网页内容
*@param $url
*@return web conntent
*/
public function get($url){
$this->curl = curl_init();
curl_setopt($this->curl, CURLOPT_URL, $url);
// 设置header
curl_setopt($this->curl, CURLOPT_HEADER, 1);
curl_setopt ($this->curl, CURLOPT_COOKIE , $this->cookie);
// 设置cURL 参数,要求结果保存到字符串中还是输出到屏幕上。
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1);
// 运行cURL,请求网页
$data = curl_exec($this->curl);
// 关闭URL请求
curl_close($this->curl);
//找到cookie 放入cookiestring
preg_match("/Set-Cookie:(.*?)\n/",$data,$r);
if(@$r[1]!=""){
if($this->cookie==""){
$this->cookie .= str_replace("\r\n","",$r[1]);
}
}
return $data;
}
/**POST方式下载网页内容
*@param $url
*@param $params post的信息串
*@return web conntent
*/
public function post($url,$params){
$this->curl = curl_init();
curl_setopt($this->curl, CURLOPT_URL, $url);
// 设置header
curl_setopt($this->curl, CURLOPT_HEADER, 1);
curl_setopt ($this->curl, CURLOPT_COOKIE , $this->cookie);
curl_setopt($this->curl, CURLOPT_POST, 1);
curl_setopt($this->curl, CURLOPT_POSTFIELDS, $params);
// 设置cURL 参数,要求结果保存到字符串中还是输出到屏幕上。
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1);
// 运行cURL,请求网页
$data = curl_exec($this->curl);
// 关闭URL请求
curl_close($this->curl);
//找到cookie 放入cookiestring
preg_match("/Set-Cookie:(.*?)\n/",$data,$r);
if(@$r[1]!=""){
if($this->cookie==""){
$this->cookie .= str_replace("\r\n","",$r[1]);
}
}
return $data;
}
}
/**飞信类
*/
class fection{
private $r;
private $httpconnector;
/**发送方手机号码
*/
private $phonenum;
/**发送方飞信密码
*/
private $pwd;
function __construct($phonenum,$pwd){
$this->phonenum=$phonenum;
$this->pwd=$pwd;
$this->httpconnector=new httpconnector();
//得到ssid
$this->httpconnector->get('http://f.10086.cn/im/login/login.action');
}
/**登陆飞信
*/
function login(){
$data=$this->httpconnector->post('http://f.10086.cn/im/login/inputpasssubmit1.action',"loginstatus=1&m=$this->phonenum&pass=$this->pwd");
@preg_match("/ontimer=\"(.*?)\"/",$data,$r);
@$r=parse_url($r[1]);
@$r=explode("=",$r['query']);
@$this->t=$r['1'];
if($this->t==""){
die("login failed");
}
}
/**退出飞信
*/
function logout(){
$this->httpconnector->get("http://f.10086.cn/im/index/logoutsubmit.action?t=$this->t");
}
/**发送飞信短信
*@param $fid 接收方的飞信id
*@param $msg 消息正文
*/
function send($fid,$msg){
$data=$this->httpconnector->post("http://f.10086.cn/im/chat/sendMsg.action?touserid=$fid","msg=$msg&touchTextLength=&touchTitle=");
if(strpos($data,"消息成功")==-1){
die("send failed");
}
if(strpos($data,"请正确输入")==-1){
die("send failed");
}
echo "success";
}
/**手机号转换为飞信id
*param $phonenum
*/
function tofid($phonenum){
//$data=$this->httpconnector->post("http://f.10086.cn/im/index/searchOtherInfoList.action?t=$this->t","searchText=$phonenum");
//print_r($data);
//找到飞信id
//preg_match("/touserid=(.*?)&/",$data,$r);
/*if(@$r[1]==""){
die("fid not found");
}*/
return $phonenum;
}
}
@$phone=$_GET["phone"];
@$pwd=$_GET["pwd"];
@$to=$_GET["to"];
@$msg=$_GET['msg'];
if(@$_GET['u']==""){//根据空间配置不同如果出现乱码请修改此处或在url上加上参数&u=1
@$msg=iconv("gbk","UTF-8",$msg);
}
if(!($phone&&$pwd&&$to&&$msg)){
die("params error. your should do Like this ?phone=xxxxxx&pwd=xxx&to=xxxx&msg=xxxx");
}
$fection=new fection($phone,$pwd);
$fection->login();
$fection->send($fection->tofid($to),$msg);
$fection->logout();
?>
最新php飞信可用api类
4星 · 超过85%的资源 需积分: 10 18 浏览量
2010-12-22
09:40:51
上传
评论
收藏 3KB ZIP 举报
ganggang4321
- 粉丝: 257
- 资源: 32
最新资源
- 555springboot + vue 线上教学平台.zip(可运行源码+数据库文件+文档)
- 554springcloud + vue 房产销售平台.zip(可运行源码+数据库文件+文档)
- 小霸王坦克游戏源码.7z
- 蓝桥杯单片机基础学习项目(LED,数码管,蜂鸣器,继电器,按键控制)
- 553springboot + vue 某银行OA系统.zip(可运行源码+数据库文件+文档)
- DatabaseWatermarkingBasedonTextFormat
- yolov8常用二维码检测检测+数据集
- -移动通信-网络课程设计与研究
- 基于Python的PCA人脸识别算法的原理及实现代码+文档详解.zip
- 甘肃移动全业务工程建设项目管理流程优化研究
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈