首页 > 代码库 > 微信开发小试

微信开发小试

<?php
/*
使用方法:
 $arr = array(
    'account' => '公众平台帐号',
    'password' => '密码'
);
$w = new Weixin($arr);
$w->getAllUserInfo();//获取用户信息
$w->sendMessage('群发内容'); //群发给所有用户
$w->sendMessage('群发内容',$userId); //群发给特定用户
*/
class Weixin {
    public $userFakeid;//所有粉丝的fakeid
    private $_account;//用户名
    private $_password;//密码
    private $url;//请求的网址
    private $send_data;//提交的数据
    private $getHeader = 0;//是否显示Header信息
    private $token;//公共帐号TOKEN
    private $host = 'mp.weixin.qq.com';//主机
    private $origin = 'https://mp.weixin.qq.com';
    private $referer;//引用地址
    private $cookie;
    private $pageSize = 100000;//每页用户数(用于读取所有用户)
    private $userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0';


    public function __construct($options){
        $this->_account = isset($options['account'])?$options['account']:'';
        $this->_password = isset($options['password'])?$options['password']:'';
        $this->login();
    }

    //登录
    private function login(){
        $url = 'https://mp.weixin.qq.com/cgi-bin/login?lang=zh_CN';
        $this->send_data = http://www.mamicode.com/array(>

微信开发小试