├── README.md ├── README.md~ └── index.php /README.md: -------------------------------------------------------------------------------- 1 | QzoneAutoReview 2 | ============= 3 | 4 | QQ空间自动评论 5 | 6 | 作者 7 | -------------- 8 | 9 | Giuem http://www.giuem.com/ 10 | 11 | 说明 12 | ---------------- 13 | 14 | http://www.giuem.com/qzone-comment-php/ 15 | 16 | http://www.anotherhome.net/1551 17 | 18 | 19 | [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/DIYgod/qzoneautoreview/trend.png)](https://bitdeli.com/free "Bitdeli Badge") 20 | 21 | -------------------------------------------------------------------------------- /README.md~: -------------------------------------------------------------------------------- 1 | QzoneAutoReview 2 | ============= 3 | 4 | QQ空间自动评论 5 | 6 | 作者 7 | -------------- 8 | 9 | Giuem http://www.giuem.com/ 10 | 11 | 其他 12 | ---------------- 13 | 14 | http://www.giuem.com/qzone-comment-php/ 15 | 16 | http://www.anotherhome.net/1551 17 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | sid = $sid; 17 | $url = "http://ish.z.qq.com/infocenter_v2.jsp?B_UID={$qq}&sid={$sid}&g_ut=2"; 18 | $re = $this->fetch($url); 19 | $this->getsaying($re); 20 | } 21 | private function fetch($url,$postdata=null){ 22 | $ch = curl_init(); 23 | curl_setopt($ch, CURLOPT_URL,$url); 24 | curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 820)"); 25 | if($postdata!=null) curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata); 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 27 | curl_setopt($ch, CURLOPT_TIMEOUT, 20); 28 | $re = curl_exec($ch); 29 | curl_close($ch); 30 | return $re; 31 | } 32 | private function getsaying($html){ 33 | preg_match_all('/<\/a>:(.*?)评论\(\d\)<\/a>/',$html,$match); 34 | foreach($match[0] as $k){ 35 | if(strstr($k,'评论(0)')){ 36 | $k = str_replace(PHP_EOL, '', $k); 37 | $k = str_replace(' ', '', $k); 38 | $k = html_entity_decode($k); 39 | preg_match('/<\/a>:(.*?)/',$k,$content); 40 | preg_match('/myfeed_mood.jsp\?sid=.*&B_(.*?)&t1_source/',$k,$data); 41 | $content = preg_replace('/]+>/', '', $content[1]); 42 | echo '找到一条说说:'.$content.' 机器人的回复是:'; 43 | $data = 'B_'.$data[1]; 44 | $content = talk($content); 45 | echo $content.'
'; 46 | $this->postcomment($content,$data); 47 | sleep(3); 48 | } 49 | } 50 | 51 | } 52 | private function postcomment($content,$data){ 53 | $postdata = "content={$content}&{$data}&t1_source=1&feedcenter_pn=1&flag=1&type=all&channel=0&back=false&offset=0&ic=false&dl=null&to_tweet=0&submit=%E8%AF%84%E8%AE%BA"; 54 | $this->fetch("http://blog30.z.qq.com/mood/mood_reply.jsp?sid={$this->sid}&g_ut=2",$postdata); 55 | } 56 | 57 | } 58 | 59 | function talk($content){ 60 | global $con,$api; 61 | if($con) return $con; 62 | $content = str_replace(' ', '', $content); 63 | if($api) return tuling($content,$api); 64 | $ch = curl_init(); 65 | curl_setopt($ch,CURLOPT_URL,'http://www.simsimi.com/talk.htm'); 66 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 67 | curl_setopt($ch, CURLOPT_HEADER,1); 68 | curl_setopt($ch, CURLOPT_NOBODY, false); 69 | $rs = curl_exec($ch); 70 | preg_match_all('/Set-Cookie: (.+)=(.+)$/m', $rs, $regs); 71 | foreach($regs[1] as $i=>$k); 72 | $cc=str_replace(' Path','' ,$k); 73 | $cc='simsimi_uid=507454034223;'.$cc; 74 | $re = HTTPClient('http://www.simsimi.com/func/reqN?lc=ch&ft=1.0&req='.$content.'&fl=http%3A%2F%2Fwww.simsimi.com%2Ftalk.htm',$cc); 75 | $re = json_decode($re,true); 76 | return $re['sentence_resp']; 77 | } 78 | function HTTPClient($url,$cookie){ 79 | $ch = curl_init(); 80 | curl_setopt($ch, CURLOPT_URL,$url); 81 | curl_setopt($ch, CURLOPT_COOKIE,$cookie); 82 | curl_setopt($ch, CURLOPT_HEADER, 0); 83 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 84 | curl_setopt($ch, CURLOPT_TIMEOUT, 30); 85 | $re = curl_exec($ch); 86 | curl_close($ch); 87 | return $re; 88 | } 89 | function tuling($content,$key){ 90 | $re = json_decode(file_get_contents('http://www.tuling123.com/openapi/api?key='.$key.'&info='.$content),true); 91 | $code = $re['code']; 92 | switch ($code){ 93 | case 100000: 94 | $content = $re['text']; 95 | break; 96 | case 200000: 97 | $content = $re['text'].$re['url']; 98 | break; 99 | case 302000: 100 | $list = $re['list']; 101 | $i = rand(0,count($list)-1); 102 | $list = $list[$i]; 103 | $content = $re['text'].':'.$list['article']; 104 | break; 105 | case 305000: 106 | $list = $re['list']; 107 | $i = rand(0,count($list)-1); 108 | $list = $list[$i]; 109 | $content = '起始站:'.$list['start'].',到达站:'.$list['terminal'].',开车时间:'.$list['starttime'].',到达时间:'.$list['endtime'].'。亲,更多信息请上网查询哦!'; 110 | break; 111 | case 306000: 112 | $list = $re['list']; 113 | $i = rand(0,count($list)-1); 114 | $list = $list[$i]; 115 | $content = '航班:'.$list['flight'].',航班路线:'.$list['route'].',起飞时间:'.$list['starttime'].',到达时间:'.$list['endtime'].'。亲,更多信息请上网查询哦!'; 116 | break; 117 | case 310000: 118 | $list = $re['list']; 119 | $i = rand(0,count($list)-1); 120 | $list = $list[$i]; 121 | $content = $list['info'].'中奖号码:'.$list['number'].'。亲,小赌怡情,大赌伤身哦!'; 122 | break; 123 | case 40004: 124 | $content = '今天累了,明天再聊吧'; 125 | break; 126 | default: 127 | //$content = xiaoji($content); 128 | $content = $re['text']; 129 | } 130 | return $content; 131 | } 132 | ?> 133 | --------------------------------------------------------------------------------