这篇文章主要介绍了PHP实现QQ空间自动回复说说的方法,涉及php基于curl调用自动回复接口的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下
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('/:(.*?)评论\(\d\)/',$html,$match);
foreach($match[0] as $k){
if(strstr($k,'评论(0)')){
$k = str_replace(PHP_EOL, '', $k);
$k = str_replace('
', '', $k);
$k = html_entity_decode($k);
preg_match('/:(.*?)/',$k,$content);//www.oicqzone.com
preg_match('/myfeed_mood.jsp\?sid=.*&B_(.*?)&t1_source/',$k,$data);
$content = preg_replace('/]+>/', '', $content[1]);
echo '找到一条说说:'.$content.' 机器人的回复是:';
$data = 'B_'.$data[1];
$content = talk($content);
echo $content.'
';
$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%2F%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;
}
?>

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

Dreamweaver Mac版
시각적 웹 개발 도구

에디트플러스 중국어 크랙 버전
작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)
