dodgepudding/wechat-php-sdk 添加登录验证码识别

其实有时间优化下,调整代码到 snoopy.class.php 用起来会方便点

Wechatext::getCode

	/**
	 * @添加验证码抓取.
	 */
	public function getCode() {
		$filename = $this->_cookiename;
		if (file_exists ( $filename )) {
			$mtime = filemtime ( $filename );
			if ($mtime < time () - $this->_cookieexpired)
				$data = '';
			else
				$data = file_get_contents ( $filename );
		} else
			$data = '';
		$send_snoopy = new Snoopy ();
		$send_snoopy->rawheaders ['Cookie'] = $data;
		$send_snoopy->maxredirs = 0;
		$url = "https://mp.weixin.qq.com/cgi-bin/verifycode?username=" . $this->_account . "&r=1406270984491";
		$send_snoopy->fetch ( $url );
		$cookie = '';
		foreach ( $send_snoopy->headers as $key => $value ) {
			$value = trim ( $value );
			if (preg_match ( '/^set-cookie:[s]+([^=]+)=([^;]+)/i', $value, $match ))
				$cookie .= $match [1] . '=' . $match [2] . '; ';
		}
		$this->saveCookie ( $this->_cookiename, $cookie );
		header ( 'Content-Type: image/jpeg' );
		echo $send_snoopy->results;
		exit ();
	}

补充验证码自动识别工具(不是做广告….)

http://www.uuwise.com/

注:微信对登录次数太多的ip做登录限制,会导致该ip的公众号无法登录。。慎玩。

发表评论

电子邮件地址不会被公开。 必填项已用*标注