Heim  >  Artikel  >  php教程  >  优酷来疯直播间模拟登录群发信息

优酷来疯直播间模拟登录群发信息

PHP中文网
PHP中文网Original
2016-05-23 17:09:551967Durchsuche


id=$idd;

    }

    //模拟登录获取yktk

    public function getkey()

    {

        $user=urldecode($this->user);

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

        $url = "http://www.laifeng.com/login/";

        $data = "userName=".$user."&password=".$pass."&forever=1&returnurl=http%3a%2f%2fwww.laifeng.com%2f7437";

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $url);

        curl_setopt($ch, CURLOPT_HEADER, 0);

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        curl_setopt($ch, CURLOPT_POST, 1);

        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

        curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookiefile);

        curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookiefile);

        curl_setopt($ch, CURLOPT_REFERER, "http://www.laifeng.com/login/");

        curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");

        $info = curl_exec($ch);

        curl_close($ch);

        $y = json_decode($info, true);

        $yktk = $y['response'];

        return $yktk;

    }

    //获取cookie

    private function login(){

        $yktk=$this->getkey();

        if($yktk['code']!=0){

            echo $yktk['msg'];

            exit();

        }else{

            $url=$yktk['data'];

            $ch=curl_init();

            curl_setopt($ch,CURLOPT_URL,$url);

            curl_setopt($ch,CURLOPT_HEADER,1);

            curl_setopt($ch,CURLOPT_COOKIEFILE,$this->cookiefile);

            curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);

            curl_setopt($ch,CURLOPT_REFERER,"http://www.laifeng.com/".$this->id);

            curl_setopt($ch,CURLOPT_COOKIEJAR,$this->cookiefile);

            curl_exec($ch);

            curl_close($ch);

            echo("
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:找不到bug的代码Nächster Artikel:QQ会员签到中用到的gtk算法