wechatext.class.php为非官方API,需要配置账户和密码,能实现主动点对点微信和批量发送,此方式不保证长期有效
Thinkphp环境下只需放到ORG目录并用import方法便可调用。
更多详细信息和更新可访问项目github地址,欢迎fork:
https://github.com/dodgepudding/wechat-php-sdk
基础API调用示例:
include "wechat.class.php"
$options = array(
'token'=>'tokenaccesskey' //填写你设定的key
);
$weObj = new Wechat($options);
$weObj->valid();
$type = $weObj->getRev()->getRevType();
switch($type) {
case Wechat::MSGTYPE_TEXT:
$weObj->text("hello, I'm wechat")->reply();
exit;
break;
case Wechat::MSGTYPE_EVENT:
break;
case Wechat::MSGTYPE_IMAGE:
break;
default:
$weObj->text("help info")->reply();
}
扩展包调用示例:include("wechatext.class.php");
function logdebug($text){
file_put_contents('./data/log.txt',$text."\n",FILE_APPEND);
};
$options = array(
'account'=>'demo@domain.com',
'password'=>'demo',
'datapath'=>'./data/cookie_',
'debug'=>true,
'logcallback'=>'logdebug'
);
$wechat = new Wechatext($options);
if ($wechat->checkValid()) {
// 获取用户信息
$data = $wechat->getInfo('3974200');
// 主动发消息
//$wechat->send('3974200','hello '.time());
var_dump($data);
}
1.1版新增以下功能:Wechatext微信发送API(非官方接口)
主要方法说明:
* send($id,$content) 向某用户id发送微信文字信息
* batch($ids,$content) 批量向一批用户发送微信文字信息
* sendNews($account,$ti
Wechatauth为非官方微信登陆API
用户通过扫描网页提供的二维码实现登陆信息获取
示例地址: http://blog.4wer.com/wechat-php-sdk
主要方法说明:
* get_login_code() 获取登陆授权码, 通过授权码才能获取二维码
* get_code_image($code='') 将上面获取的授权码转换为图片二维码
* verify_code() 鉴定是否登陆成功,返回200为最终授权成功.
* get_login_cookie() 鉴定成功后调用此方法即可获取用户基本信息
* sendNews($account,$ti