国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PHP > 正文

PHP實(shí)現(xiàn)QQ空間自動(dòng)回復(fù)說說的方法

2024-05-04 23:40:42
字體:
供稿:網(wǎng)友
這篇文章主要介紹了PHP實(shí)現(xiàn)QQ空間自動(dòng)回復(fù)說說的方法,涉及php基于curl調(diào)用自動(dòng)回復(fù)接口的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
 

本文實(shí)例講述了PHP實(shí)現(xiàn)QQ空間自動(dòng)回復(fù)說說的方法。分享給大家供大家參考,具體如下:

<?php header("Content-type: text/html; charset=utf-8"); $qq = '';//QQ號(hào) $sid = '';//填寫sid的值 $con = '';//自定義內(nèi)容,留空則使用simsimi $qzone = new qzone($qq,$sid); class qzone{   private $sid ='';   public function __construct($qq,$sid){     $this->sid = $sid;     $url = "http://ish.z.qq.com/infocenter_v2.jsp?B_UID={$qq}&sid={$sid}&g_ut=2";     $re = $this->fetch($url);     $this->getsaying($re);   }   private function fetch($url,$postdata=null){     $ch = curl_init();//www.oicqzone.com     curl_setopt($ch, CURLOPT_URL,$url);     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)");     if($postdata!=null) curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata);     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);     curl_setopt($ch, CURLOPT_TIMEOUT, 20);     $re = curl_exec($ch);     curl_close($ch);     return $re;   }   private function getsaying($html){     preg_match_all('/<//a>:(.*?)評(píng)論/(/d/)<//a>/',$html,$match);     foreach($match[0] as $k){       if(strstr($k,'評(píng)論(0)')){         $k = str_replace(PHP_EOL, '', $k);         $k = str_replace('', '', $k);         $k = html_entity_decode($k);         preg_match('/<//a>:(.*?)<span class="txt-fade">/',$k,$content);//www.oicqzone.com         preg_match('/myfeed_mood.jsp/?sid=.*&B_(.*?)&t1_source/',$k,$data);         $content = preg_replace('/<img[^>]+>/', '', $content[1]);         echo '找到一條說說:'.$content.' 機(jī)器人的回復(fù)是:';         $data = 'B_'.$data[1];         $content = talk($content);         echo $content.'<br />';         $this->postcomment($content,$data);         sleep(3);       }     }   }   private function postcomment($content,$data){     $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";     $this->fetch("http://blog30.z.qq.com/mood/mood_reply.jsp?sid={$this->sid}&g_ut=2",$postdata);     } } function talk($content){     global $con;     if($con) return $con;   $content = str_replace(' ', '', $content);     $ch = curl_init();   curl_setopt($ch,CURLOPT_URL,'http://www.simsimi.com/talk.htm');   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);   curl_setopt($ch, CURLOPT_HEADER,1);   curl_setopt($ch, CURLOPT_NOBODY, false);   $rs = curl_exec($ch);   preg_match_all('/Set-Cookie: (.+)=(.+)$/m', $rs, $regs);   foreach($regs[1] as $i=>$k);   $cc=str_replace(' Path','' ,$k);   $cc='simsimi_uid=507454034223;'.$cc;   $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);   $re = json_decode($re,true);   return $re['sentence_resp']; } function HTTPClient($url,$cookie){   $ch = curl_init();   curl_setopt($ch, CURLOPT_URL,$url);   curl_setopt($ch, CURLOPT_COOKIE,$cookie);   curl_setopt($ch, CURLOPT_HEADER, 0);   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);   curl_setopt($ch, CURLOPT_TIMEOUT, 30);   $re = curl_exec($ch);   curl_close($ch);   return $re; } ?>

希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。



注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到PHP教程頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 通化市| 武川县| 杭锦后旗| 朔州市| 林甸县| 依安县| 布尔津县| 宜都市| 南陵县| 石楼县| 和龙市| 二连浩特市| 保靖县| 皮山县| 津南区| 玉门市| 三亚市| 大新县| 竹山县| 开鲁县| 丹巴县| 齐齐哈尔市| 陇川县| 邵武市| 安顺市| 顺昌县| 西充县| 新营市| 临泉县| 河源市| 黄平县| 呼图壁县| 东辽县| 东乌珠穆沁旗| 八宿县| 沐川县| 荔波县| 土默特左旗| 建平县| 宝应县| 张家港市|