我也是最近才看到的,大家可以到网上搜索一下QQ的http协议,实现很简单,我只是稍微试了一下,写了以下几段代码,如果哪位有兴趣可以继续研究。如果有J2ME或者各大手机厂商的SDK,研究一下javaQQ也不错。最近要考试,只能先贴出来,先说明,未全部完成

代码:

class Query {

private $timeout;// = 100; // Max time for stablish the conection

private $server;// = '219.133.51.11';//'219.133.51.11'; // IP address

private $host;// = 'tqq.tencent.com'; // Domain name

private $port;// = 8000;

private $postValues;// = array ( 'VER' => '1.1',

private $ret;

public function go(){

$this->postValues = substr( $this->postValues, 0, -1 );

$request = "POST HTTP/1.1\r\n";

$request .= "Host: $this->host\r\n";

$length = strlen( $this->postValues );

$request .= "Content-Type: application/x-www-form-urlencoded\r\n";

$request .= "Content-Length: $length\r\n";

$request .= "\r\n";

$request .= $this->postValues;

$socket = fsockopen( $this->server, $this->port, $errno, $errstr, $this->timeout );

fputs( $socket, $request );

$ret = '';

while ( !feof( $socket ) ) {

$ret .= fgets( $socket, 4096 );

}

fclose( $socket );

$this->setRetValues( $ret );

}

public function clearParams() {

$this->postValues = '';

return true;

}

public function addParams( $var , $value ) {

$this->postValues.= urlencode( $var ) . "=" . urlencode( $value ) . '&';

}

public function setTimeout( $timeout ) {

$this->timeout = $timeout;

return true;

}

public function setServer( $server ) {

$this->server = $server;

return true;

}

public function setHost( $host ) {

$this->host = $host;

return true;

}

public function setPort( $port ) {

$this->port = $port;

return true;

}

public function getRetValues() {

parse_str(iconv('UTF-8','GB2312',$this->ret),$arrValues);

return $arrValues;

//return $this->ret;

}

private function setRetValues( $ret ) {

$this->ret=$ret;

return ture;

}

}

?>

class QQ {

private $query;

private $no;

private $pass;

public function login() {

$this->query->clearParams();

$this->query->addParams('VER','1.1');

$this->query->addParams('CMD','Login');

$this->query->addParams('SEQ',rand(1000,9000));

$this->query->addParams('UIN',$this->no);

$this->query->addParams('PS',$this->pass);

$this->query->addParams('M5','1');

$this->query->addParams('LC','9326B87B234E7235');

$this->query->go();

return $this->query->getRetValues();

}

public function getFriendList() {

// VER=1.1&CMD=List&SEQ=&UIN=&TN=160&UN=0

$this->query->clearParams();

$this->query->addParams('VER','1.1');

$this->query->addParams('CMD','List');

$this->query->addParams('SEQ',rand(1000,9000));

$this->query->addParams('UIN',$this->no);

$this->query->addParams('TN','160');

$this->query->addParams('UN','0');

//$this->query->addParams('LC','9326B87B234E7235');

$this->query->go();

return $this->query->getRetValues();

}

public function changeStat($st) {

$this->query->clearParams();

$this->query->addParams('VER','1.1');

$this->query->addParams('CMD','Change_Stat');

$this->query->addParams('SEQ',rand(1000,9000));

$this->query->addParams('UIN',$this->no);

$this->query->addParams('ST',$st);

$this->query->go();

return $this->query->getRetValues();

//VER=1.1&CMD=Change_Stat&SEQ=&UIN=&ST=

//ST为要改变的状态,10为上线,20为离线,30为忙碌。

}

public function getMsg() {

//VER=1.1&CMD=GetMsgEx&SEQ=&UIN=

$this->query->clearParams();

$this->query->addParams('VER','1.1');

$this->query->addParams('CMD','GetMsgEx');

$this->query->addParams('SEQ',rand(1000,9000));

$this->query->addParams('UIN',$this->no);

$this->query->go();

return $this->query->getRetValues();

}

public function getUserInfo($user_no) {

// VER=1.1&CMD=GetInfo&SEQ=&UIN=&LV=2&UN=

$this->query->clearParams();

$this->query->addParams('VER','1.1');

$this->query->addParams('CMD','GetInfo');

$this->query->addParams('SEQ',rand(1000,9000));

$this->query->addParams('UIN',$this->no);

$this->query->addParams('LV','2');

$this->query->addParams('UN',$user_no);

$this->query->go();

echo time().' '.(double)microtime(true).'
';

//echo $user_no.'ok';

//print_r( $this->query->getRetValues());

}

public function setQQInfo( $no , $pass ) {

$this->no = $no;

$this->pass = md5($pass);

return true;

}

public function setQuery($query) {

$this->query = $query;

return true;

}

}

?>

相关标签:php

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

php qq对话,用php聊QQ相关推荐

  1. php qq对话,PHP WEB版QQ多人聊天

    制作WEB版QQ多人聊天过程中, 无法将数据插入数据库,查找了多遍,实在不知哪里有错误,请各位老师帮忙看一下,给指点,非常感谢! 下面是各文件: //my.js function getXmlHttp ...

  2. 怎么将几个QQ对话窗口合并和分离

    https://jingyan.baidu.com/article/f25ef25474eb8a482d1b8262.html 怎么将几个QQ对话窗口合并和分离 怎么将几个QQ对话窗口合并和分离 听语 ...

  3. java仿QQ聊天室群聊(快速写一个简易QQ)

    [mie haha的博客]转载请注明出处(万分感谢!): https://blog.csdn.net/qq_40315080/article/details/83052689 用java写聊天室实现群 ...

  4. 链接直接打开QQ对话窗口

    <a class="button right" href="http://wpa.qq.com/msgrd?v=3&uin=123456&site= ...

  5. ecshop打开手机端QQ对话窗口

    ecshop的手机功能比较弱,默认的模板很丑,也不带打开手机端QQ等功能,在程序里添加im等程序变量后,在模板里引入以下代码,即可打开手机端qq对话窗口 <!-- QQ 号码 {foreach ...

  6. C++打开网页,发起QQ对话,调用外部exe程序

    本文介绍了C++如何打开网页,发起QQ对话. 用默认浏览器打开一个网页 ShellExecute(NULL, _T("open"), _T("http://my.csdn ...

  7. 解决Mac能上微信聊QQ但是打不开网页的问题

    解决Mac能上微信聊QQ但是打不开网页的问题 1.在访达中,前往文件夹 2.操作截图 复制代码 /Library/Preferences/SystemConfiguration/com.apple.B ...

  8. 电脑不能上网页,但是能聊QQ,是怎么回事?

    首先,说说怎么办. 电脑不能上网页,但是能聊QQ,是电脑上的DNS被劫持了.在上网的时候,由于不小心安装了某些不好的软件,就会出现这个情况. 首先我们应该  1.打开网络和Internet. 2.点击 ...

  9. 打开页面自动强制QQ对话

    打开页面自动强制QQ对话 <meta http-equiv="refresh" content="0; url=tencent://AddContact/?from ...

最新文章

  1. Python设置环境变量,改变GnomeConnectionManager的语言
  2. 知名美国服务器租用商介绍
  3. 计算机二级find,Excel函数-find、if和iferror-计算机二级Office
  4. Python瓦匠 —— 正则表达式(五)
  5. 【快乐水题】2000. 反转单词前缀
  6. 系统测试与端到端测试:哪一个更适合选择?
  7. Java hibernate假外键_JAVA基础:Hibernate外键关联与HQL语法
  8. 现代ups电源及电路图集_2020山特UPS电源自动开机200KVA实力
  9. Android 灯光系统开发
  10. 一个实例明白AutoResetEvent和 ManulResetEvent的用法
  11. 【Hack The Box】windows练习-- Conceal
  12. qml之TextArea 添加滚动条
  13. 华为android怎么打开usb调试,华为PLK-AL10 开启USB调试模式
  14. 显示文件内容时显示行号命令nl
  15. Android 天气APP(三十六)运行到本地AS、更新项目版本依赖、去掉ButterKnife
  16. burg算法 matlab,基于burg算法的谱估计研究及其matlab实现.doc
  17. 9月20日云栖精选夜读:异构计算高性能计算分论坛——揭秘拿什么实现超算平民化、国际化?
  18. python以图搜图api_网络图片搜索-以图搜图【最新版】_自动识别接口_图像识别_数据API-云市场-阿里云...
  19. Pytorch中的einsum
  20. Poj·Dessert

热门文章

  1. 词移距离 Word Mover‘s Distance
  2. 三大测序平台芯片通量对比图
  3. 大学mysql教程_MYSQL教程:新手该看的MYSQL操作
  4. mvc登录实例 mysql_spring mvc + mybatis + mysql 调整的一个简单的登录例子
  5. 社团发现算法-BGLL算法(附代码实现)
  6. java accept encoding_Accept-Encoding gzip 乱码 和Okhttp的解决方法
  7. linux 系统目录 java_Linux系统目录及说明
  8. 计算机导航辅助教程,计算机导航辅助下微创人工全膝关节置换的初步经验
  9. python -opencv 使用滑动条 cv2.createTrackbar,cv2.getTrackbarPos(), cv2.setTrackbarPos
  10. 【rnnoise源码分析】compute_frame_feature函数