php使用curl抓取qq空间的访客信息示例(15)

public function  rightFrameVisitor()
    {
        $param = Utils ::getGTK($this->getCookie('qzone_visitor_param', true));
        $referver = Utils ::getGTK($this->getCookie('qzone_referer'));

$options = array(
            CURLOPT_TIMEOUT => $this->request_timeout,
            CURLOPT_HEADER => 1,
            CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_URL => 'http://r.qzone.qq.com/cgi-bin/right_frame.cgi?' . http_build_query(array(
                'uin' => $this->user,
                'param' => $param,
                'g_tk' => $this->getGTKEncryption(),
            )),

CURLOPT_HTTPHEADER => array(
                'Referer:' . $referver,
                'User-Agent:' . $this->user_agent,
                'Host:r.qzone.qq.com',
                'Connection:keep-alive',
            )
        );

return ResultExtract::rightFrameVisitors($this->requestExec($options));
    }

}

class CCKFServiceRequest extends BaseRequest
{
    protected $service_address;
    protected $service_id;
    protected $security_key;

public function __construct($security_key, $service_id, $service_address, $cookie_file, $request_timeout, $debug, $end_line)
    {
        parent:: __construct($cookie_file, $request_timeout, $debug, $end_line);
        $this->service_address = $service_address;
        $this->service_id = $service_id;
        $this->security_key = $security_key;
    }
}

class CCKFService extends BaseRequest
{
    public function __construct($security_key, $service_id, $service_address, $cookie_file, $request_timeout, $debug, $end_line)
    {
        parent:: __construct($security_key, $service_id, $service_address, $cookie_file, $request_timeout, $debug, $end_line);
    }

public function uploadData($data)
    {
        if (is_array($data) && !empty($data)) {
            $options = array(
                CURLOPT_TIMEOUT => $this->request_timeout,
                CURLOPT_HEADER => 1,
                CURLOPT_RETURNTRANSFER => 1,
                CURLOPT_URL => $this->service_address . '?' . http_build_query(array()),
            );
        }
    }
}

class BaseConfigFileUtils
{
    protected $file;

public function __construct($file)
    {
        $this->file = $file;
    }

public function extractFile()
    {
        $f_str = '';

$fp = fopen($this->file, 'r');
        if (flock($fp, LOCK_SH)) {
            while (!feof($fp)) {
                $f_str .= fgets($fp);
            }
            flock($fp, LOCK_UN);
        }
        fclose($fp);
        $c = json_decode($f_str, true);
        return is_array($c) ? $c : array();
    }
}

class RunAtTimeConfig extends BaseConfigFileUtils
{
    protected $visitor_capture_interval;
    protected $config;

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/6a3b396fe61b016e0da9eb2453f6669b.html