使用者透過掃描網頁提供的二維碼實現登陸資訊獲取
-
/**
- * 微信公眾平台PHP-SDK
- * Wechatauth為非官方微信登陸API
- * 使用者透過掃描網頁提供的二維碼實現登陸資訊取得
- * 主要實現以下功能:
- * get_login_code() 取得登陸授權碼, 透過授權碼才能取得二維碼
- * get_code_image($code='') 將上面取得的授權碼轉換為圖片二維碼
- * verify_code() 鑑定是否登陸成功,回傳200為最終授權成功.
- * get_login_cookie() 鑑定成功後呼叫此方法即可取得使用者基本資訊
- * sendNews($account,$title,$summary,$content,$pic, $srcurl='') 向一個微信帳戶發送圖文資訊
- * get_avatar($url) 取得使用者頭像圖片資料
- * @author dodge
- * [url=home .php?mod=space&uid=17823]@LINK[/url] https://github.com/dodgepudding/wechat-php-sdk
- * @version 1.1
- *
- */
- include "snoopy.class.php";
- class Wechatauth
- {
- {
- private $cookie;
- private $_cookiename;
- private $_cookieexpired = 3600;
- private $_account = 'test';
- private $_data = 'private $_account = 'test';
- private $_data = './/data/ookie^'ate; $debug;
- private $_logcallback;
- public $login_user; //目前登陸使用者, 呼叫get_login_info後取得
-
- public function __construct($options)
- {🎜> public function __construct($options)
- { $_account = isset($options['account'])?$options['account']:'';
- $this->_datapath = isset($options['datapath'])?$options['datapath ']:$this->_datapath;
- $this->debug = isset($options['debug'])?$options['debug']:false;
- $this->_logcallback = isset( $options['logcallback'])?$options['logcallback']:false;
- $this->_cookiename = $this->_datapath.$this->_account;
- $this->getCookie($ this->_cookiename);
- }
- /**
- * 把cookie寫入快取
- * @param string $filename 快取檔案名稱
- * @param string $content 檔案內容
- * @return bool
- */
- public function saveCookie($filename,$content){
- return file_put_contents($filename,$content);
- return file_put_contents($filename,$content);
- }
-
- /**
- * 讀取cookie快取內容
- * @param string $filename 快取檔案名稱
- * @return string cookie
- */
- public function getCookie($filename){
- if (file_exists($filename)) {
- $mtime = filemtime($filename) ;
- if ($mtime
$send_snoopy->rawheaders['Cookie']= $ this ->cookie; $send_snoopy->referer = "https://wx.qq.com/"; $send_snoopy->submit($submit,array('uin'=>; $uid,' sid'=>$sid)); $this->deleteCookie($this->_cookiename); return true; | }
}