PHP code example of tianye / wechat-mp-sdk

1. Go to this page and download the library: Download tianye/wechat-mp-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tianye / wechat-mp-sdk example snippets


<?
  /**
      * 接口初始化, 必须执行此方法才可以使用接口.
      *
      * @param string $appid
      * @param string $appsecret        服务号APP_SECRET
      * @param string $originalid       服务号ORIGINAL_ID
      * @param string $token            服务号TOKEN
      * @param string $encoding_aes_key 服务号ENCODING_AES_KEY
      * @param string $apiurl           微信接口地址 APIURL 默认 微信接口 地址 可以 自定义 Proxy
      * @param string $cacheDriver      缓存驱动 Redis File ThinkPHP(兼容项目-不建议使用) ......
      */
 Api::init($appid, $appsecret, $originalid, $token, $encoding_aes_key, $apiurl, $cacheDriver);

$WxApi = Api::factory('Auth');
$ret   = $WxApi->url();  //无参数请求

string(223) "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23732ac865d46fa2&redirect_uri=http%3A%2F%2Fwww.home-mpdemo.com%2Findex.php%2FHome%2FAuth%2Furl&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"

$WxApi = Api::factory('Auth');
$ret   = $WxApi->redirect();  //无参数请求

$WxApi = Api::factory('Auth');
if (!I('get.state', false, 'htmlspecialchars') || (!$code = I('get.code', false, 'htmlspecialchars')) && I('get.state', false, 'htmlspecialchars')) {
  	$redirect = $WxApi->redirect(); //直接跳转
}

$permission = $this->getAccessPermission($code); //通过 code 获取 openid 和 access_token
$ret = $WxApi->getUser($permission['openid'], $permission['access_token']);//获取用户信息

string(85) "错误码:41001, 错误信息:access_token missing, hints: [ req_id: RJ0HeA0325ns47 ]"

$WxApi = Api::factory('Auth');
if (!I('get.state', false, 'htmlspecialchars') || (!$code = I('get.code', false, 'htmlspecialchars')) && I('get.state', false, 'htmlspecialchars')) {
  	$redirect = $WxApi->redirect(); //直接跳转
}
$ret = $WxApi->user(); //获取授权用户信息

string(0) ""

$WxApi = Api::factory('Auth');
$ret   = $WxApi->authorize();

$WxApi = Api::factory('Auth');
if (!I('get.state', false, 'htmlspecialchars') || (!$code = I('get.code', false, 'htmlspecialchars')) && I('get.state', false, 'htmlspecialchars')) {
  $redirect = $WxApi->redirect(); //直接跳转
}

$permission = $this->getAccessPermission($code); //通过 code 获取 openid 和 access_token
$ret = $WxApi->accessTokenIsValid($permission['openid'], $permission['access_token']); //获取用户信息

$WxApi = Api::factory('Card');
$ret = $WxApi->getcolors();

array(14) {
  [0]=>
  array(2) {
    ["name"]=>
    string(8) "Color010"
    ["value"]=>
    string(7) "#63b359"
  }
  [1]=>
  array(2) {
    ["name"]=>
    string(8) "Color020"
    ["value"]=>
    string(7) "#2c9f67"
  }
  [2]=>
  array(2) {
    ["name"]=>
    string(8) "Color030"
    ["value"]=>
    string(7) "#509fc9"
  }
  [3]=>
  array(2) {
    ["name"]=>
    string(8) "Color040"
    ["value"]=>
    string(7) "#5885cf"
  }
  [4]=>
  array(2) {
    ["name"]=>
    string(8) "Color050"
    ["value"]=>
    string(7) "#9062c0"
  }
  [5]=>
  array(2) {
    ["name"]=>
    string(8) "Color060"
    ["value"]=>
    string(7) "#d09a45"
  }
  [6]=>
  array(2) {
    ["name"]=>
    string(8) "Color070"
    ["value"]=>
    string(7) "#e4b138"
  }
  [7]=>
  array(2) {
    ["name"]=>
    string(8) "Color080"
    ["value"]=>
    string(7) "#ee903c"
  }
  [8]=>
  array(2) {
    ["name"]=>
    string(8) "Color081"
    ["value"]=>
    string(7) "#f08500"
  }
  [9]=>
  array(2) {
    ["name"]=>
    string(8) "Color082"
    ["value"]=>
    string(7) "#a9d92d"
  }
  [10]=>
  array(2) {
    ["name"]=>
    string(8) "Color090"
    ["value"]=>
    string(7) "#dd6549"
  }
  [11]=>
  array(2) {
    ["name"]=>
    string(8) "Color100"
    ["value"]=>
    string(7) "#cc463d"
  }
  [12]=>
  array(2) {
    ["name"]=>
    string(8) "Color101"
    ["value"]=>
    string(7) "#cf3e36"
  }
  [13]=>
  array(2) {
    ["name"]=>
    string(8) "Color102"
    ["value"]=>
    string(7) "#5E6671"
  }
}


$type = 'groupon';

$base_info                  = [];
$base_info['logo_url']      = 'http://mmbiz.qpic.cn/mmbiz/2aJY6aCPatSeibYAyy7yct9zJXL9WsNVL4JdkTbBr184gNWS6nibcA75Hia9CqxicsqjYiaw2xuxYZiaibkmORS2oovdg/0';
$base_info['brand_name']    = '测试商户造梦空间';
$base_info['code_type']     = 'CODE_TYPE_QRCODE';
$base_info['title']         = '测试标题2';
$base_info['sub_title']     = '测试副标题';
$base_info['color']         = 'Color010';
$base_info['notice']        = '测试使用时请出示此券';
$base_info['service_phone'] = '15311931577';
$base_info['description']   = "测试不可与其他优惠同享\n如需团购券发票,请在消费时向商户提出\n店内均可使用,仅限堂食";

$base_info['date_info']                     = [];
$base_info['date_info']['type']             = 'DATE_TYPE_FIX_TERM';
$base_info['date_info']['fixed_term']       = 90; //表示自领取后多少天内有效,不支持填写0
$base_info['date_info']['fixed_begin_term'] = 0; //表示自领取后多少天开始生效,领取后当天生效填写0。

$base_info['sku']             = [];
$base_info['sku']['quantity'] = '500000'; //自定义code时设置库存为0

$base_info['get_limit']       = 1;
$base_info['use_custom_code'] = false; //自定义code时必须为true
// $base_info['get_custom_code_mode'] = "GET_CUSTOM_CODE_MODE_DEPOSIT";  //自定义code时设置
$base_info['bind_openid']          = false;
$base_info['can_share']            = true;
$base_info['can_give_friend']      = false;
$base_info['center_title']         = '顶部居中按钮';
$base_info['center_sub_title']     = '按钮下方的wording';
$base_info['center_url']           = 'http://www.qq.com';
$base_info['custom_url_name']      = '立即使用';
$base_info['custom_url']           = 'http://www.qq.com';
$base_info['custom_url_sub_title'] = '6个汉字tips';
$base_info['promotion_url_name']   = '更多优惠';
$base_info['promotion_url']        = 'http://www.qq.com';
$base_info['source']               = '造梦空间';

$especial                = [];
$especial['deal_detail'] = "deal_detail";

$WxApi = Api::factory('Card');

$ret = $WxApi->create($type, $base_info, $especial);

string(28) "pdkJ9uCzKWebwgNjxosee0ZuO3Os"

string(142) "错误码:41011, 错误信息:missing 

$card                                          = [];
$card['action_name']                           = 'QR_CARD';
$card['expire_seconds']                        = 1800;
$card['action_info']['card']['card_id']        = 'pdkJ9uGXfjw6Thm7iJakUSru5sqE';
$card['action_info']['card']['is_unique_code'] = false;
$card['action_info']['card']['outer_id']       = 1;

//领取多张卡券
$card_list                                              = [];
$card_list['action_name']                               = 'QR_MULTIPLE_CARD';
$card_list['action_info']['multiple_card']['card_list'] = [
  ['card_id' => 'pdkJ9uGXfjw6Thm7iJakUSru5sqE'],
  // ['card_id' => 'pdkJ9uItT7iUpBp4GjZp8Cae0Vig'],
  // ['card_id' => 'pdkJ9uFiwIfiNod7J6zqTI3zbiyU'],
  ];

$WxApi = Api::factory('Card');

$ret = $WxApi->qrcode($card_list);

array(4) {
  ["ticket"]=>
  string(96) "gQHa7joAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xLzdrUFlQMHJsV3Zvanc5a2NzV1N5AAIEJUVyVwMEAKd2AA=="
  ["expire_seconds"]=>
  int(7776000)
  ["url"]=>
  string(43) "http://weixin.qq.com/q/7kPYP0rlWvojw9kcsWSy"
  ["show_qrcode_url"]=>
  string(151) "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQHa7joAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xLzdrUFlQMHJsV3Zvanc5a2NzV1N5AAIEJUVyVwMEAKd2AA%3D%3D"
}

string(68) "错误码:40073, 错误信息:invalid card id hint: [rScPNA0536ent2]"

$WxApi = Api::factory('Card');
$ticket = 'gQFF8DoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL01VTzN0T0hsS1BwUlBBYUszbVN5AAIEughxVwMEAKd2AA==';
$ret = $WxApi->showqrcode($ticket);

$WxApi = Api::factory('Card');
$ticket = 'gQFF8DoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL01VTzN0T0hsS1BwUlBBYUszbVN5AAIEughxVwMEAKd2AA==';
$ret = $WxApi->showqrcode_url($ticket);

string(145) "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQFF8DoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL01VTzN0T0hsS1BwUlBBYUszbVN5AAIEughxVwMEAKd2AA"

$WxApi = Api::factory("Card");
$ret = $WxApi->cardApiTicket(true);

string(86) "E0o2-at6NcC2OsJiQTlwlMzp8db8D6ZMid6Kw29Gy8v4n0lXbKq4N7fX6WaGG1jvlNr58WBUcfz5i8ghXuU_AQ"

$WxApi = Api::factory('Card');
$card_list = [
  ['card_id' => 'pdkJ9uLRSbnB3UFEjZAgUxAJrjeY', 'outer_id' => 2],
  // ['card_id' => 'pdkJ9uJ37aU-tyRj4_grs8S45k1c', 'outer_id' => 3],
  // ['card_id' => 'pdkJ9uFiwIfiNod7J6zqTI3zbiyU', 'outer_id' => 4],
];
$ret = $WxApi->wxCardPackage($card_list);

string(199) "{"cardList":[{"cardId":"pdkJ9uLRSbnB3UFEjZAgUxAJrjeY","cardExt":"{\"code\":\"\",\"openid\":\"\",\"timestamp\":1467109797,\"signature\":\"73ba424fc1aabfa62e752ee5fd8fee4610e2a610\",\"outer_id\":2}"}]}"

$banner     = 'http://mmbiz.qpic.cn/mmbiz/iaL1LJM1mF9aRKPZJkmG8xXhiaHqkKSVMMWeN3hLut7X7hicFN';
$page_title = '惠城优惠大派送';
$can_share  = true;

//SCENE_NEAR_BY          附近
//SCENE_MENU             自定义菜单
//SCENE_QRCODE             二维码
//SCENE_ARTICLE             公众号文章
//SCENE_H5                 h5页面
//SCENE_IVR                 自动回复
//SCENE_CARD_CUSTOM_CELL 卡券自定义cell
$scene = 'SCENE_NEAR_BY';
$card_list = [
  ['card_id' => 'pdkJ9uLRSbnB3UFEjZAgUxAJrjeY', 'thumb_url' => 'http://test.digilinx.cn/wxApi/Uploads/test.png'],
  // ['card_id' => 'pdkJ9uJ37aU-tyRj4_grs8S45k1c', 'thumb_url' => 'http://test.digilinx.cn/wxApi/Uploads/aa.jpg'],
];

$WxApi = Api::factory('Card');
$ret = $WxApi->landingpage($banner, $page_title, $can_share, $scene, $card_list);

array(2) {
  ["url"]=>
  string(256) "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx3be6367203f983ac&redirect_uri=https%3A%2F%2Fmp.weixin.qq.com%2Fbizmall%2Fcardlandingpage%3Fbiz%3DMzA5NTIxNjc1OA%3D%3D%26page_id%3D7%26scene%3D1&response_type=code&scope=snsapi_base#wechat_redirect"
  ["page_id"]=>
  int(7)
}

string(68) "错误码:40073, 错误信息:invalid card id hint: [Pc._7a0871ent3]"

$card_id = 'pdkJ9uLCEF_HSKO7JdQOUcZ-PUzo';
$code    = ['11111', '22222', '33333'];

$WxApi = Api::factory('Card');
$ret = $WxApi->deposit($card_id, $code);

array(3) {
  ["succ_code"]=>
  array(0) {
  }
  ["duplicate_code"]=>
  array(3) {
    [0]=>
    string(5) "11111"
    [1]=>
    string(5) "22222"
    [2]=>
    string(5) "33333"
  }
  ["fail_code"]=>
  array(0) {
  }
}

string(68) "错误码:40073, 错误信息:invalid card id hint: [wlqR7a0200ent3]"

$card_id = 'pdkJ9uLCEF_HSKO7JdQOUcZ-PUzo';

$WxApi = Api::factory('Card');
$ret = $WxApi->getdepositcount($card_id);

int(12)

string(68) "错误码:40073, 错误信息:invalid card id hint: [VkCjKa0425ent2]"

$card_id = 'pdkJ9uLCEF_HSKO7JdQOUcZ-PUzo';
$code    = ['807732265476', '22222', '33333'];

$WxApi = Api::factory('Card');
$ret = $WxApi->checkcode($card_id, $code);

array(2) {
  ["exist_code"]=>
  array(2) {
    [0]=>
    string(5) "22222"
    [1]=>
    string(5) "33333"
  }
  ["not_exist_code"]=>
  array(1) {
    [0]=>
    string(12) "807732265476"
  }
}

string(68) "错误码:40073, 错误信息:invalid card id hint: [XD3LHA0836ent3]"

$card_id = 'pdkJ9uLRSbnB3UFEjZAgUxAJrjeY11';

$WxApi = Api::factory('Card');
$ret = $WxApi->gethtml($card_id);

string(68) "错误码:40073, 错误信息:invalid card id hint: [dJj46a0155ent1]"

$openid   = [];
$username = ['tianye0327'];

$WxApi = Api::factory('Card');
$ret = $WxApi->testwhitelist($openid, $username);$card_id = 'pdkJ9uLRSbnB3UFEjZAgUxAJrjeY11';

array(3) {
  ["white_list_size"]=>
  int(1)
  ["success_openid"]=>
  array(0) {
  }
  ["success_username"]=>
  array(1) {
    [0]=>
    string(10) "tianye0327"
  }
}

$code          = '8077322654761';
$check_consume = true;
$card_id       = 'pdkJ9uLRSbnB3UFEjZAgUxAJrjeY';

$WxApi = Api::factory('Card');
$ret = $WxApi->codeGet($code, $check_consume, $card_id);


array(4) {
  ["card"]=>
  array(4) {
    ["card_id"]=>
    string(28) "pdkJ9uGXfjw6Thm7iJakUSru5sqE"
    ["begin_time"]=>
    int(1467043200)
    ["end_time"]=>
    int(1474819199)
    ["code"]=>
    string(12) "801586007419"
  }
  ["openid"]=>
  string(28) "odkJ9uDUz26RY-7DN1mxkznfo9xU"
  ["can_consume"]=>
  bool(true)
  ["user_card_status"]=>
  string(6) "NORMAL"
}

string(72) "错误码:40056, 错误信息:invalid serial code hint: [Na1y7a0585ent3]"

$card_id = 'pdkJ9uLRSbnB3UFEjZAgUxAJrjeY';
$code    = '807732265476';

$WxApi = Api::factory('Card');
$ret = $WxApi->consume($code, $card_id);

array(2) {
  	["card"]=> array(1) { 
    	["card_id"]=> string(28) "pdkJ9uLRSbnB3UFEjZAgUxAJrjeY"
  	} 
  	["openid"]=> string(28) "odkJ9uDUz26RY-7DN1mxkznfo9xU"
}

string(90) "错误码:40099, 错误信息:invalid code, this code has consumed. hint: [W0HW.a0437ent2]"

$encrypt_code = 'XXIzTtMqCxwOaawoE91+VJdsFmv7b8g0VZIZkqf4GWA60Fzpc8ksZ/5ZZ0DVkXdE';

$WxApi = Api::factory('Card');
$ret = $WxApi->decrypt($encrypt_code);

string(12) "992718526867"  //解密后获取的真实Code码

string(71) "错误码:40075, 错误信息:invalid encrypt code hint: [ohmq0908ent1]"

$openid  = 'pdkJ9uLRSbnB3UFEjZAgUxAJrjeY';
$card_id = ''; //卡券ID。不填写时默认查询当前appid下的卡券。

$WxApi = Api::factory('Card');
$ret = $WxApi->getcardlist($openid, $card_id);

array(2) {
  ["card_list"]=>
  array(8) {
    [0]=>
    array(2) {
      ["card_id"]=>
      string(28) "pdkJ9uDgnm0pKfrTb1yV0dFMO_Gk"
      ["code"]=>
      string(12) "736052543512"
    }
    [1]=>
    array(2) {
      ["card_id"]=>
      string(28) "pdkJ9uDgnm0pKfrTb1yV0dFMO_Gk"
      ["code"]=>
      string(12) "774759815535"
    }
  }
  ["has_share_card"]=>
  bool(false)
}

string(67) "错误码:40003, 错误信息:invalid openid hint: [.TpvQA0500ent3]"

$card_id = 'pdkJ9uLRSbnB3UFEjZAgUxAJrjeY';

$WxApi = Api::factory('Card');
$ret = $WxApi->cardGet($card_id);

array(2) {
  ["card_type"]=>
  string(7) "GROUPON"
  ["groupon"]=>
  array(3) {
    ["base_info"]=>
    array(31) {
      ["id"]=>
      string(28) "pdkJ9uLRSbnB3UFEjZAgUxAJrjeY"
      ["logo_url"]=>
      string(122) "http://mmbiz.qpic.cn/mmbiz/2aJY6aCPatSeibYAyy7yct9zJXL9WsNVL4JdkTbBr184gNWS6nibcA75Hia9CqxicsqjYiaw2xuxYZiaibkmORS2oovdg/0"
      ["code_type"]=>
      string(16) "CODE_TYPE_QRCODE"
      ["brand_name"]=>
      string(24) "测试商户造梦空间"
      ["title"]=>
      string(12) "测试标题"
      ["sub_title"]=>
      string(15) "测试副标题"
      ["date_info"]=>
      array(3) {
        ["type"]=>
        string(18) "DATE_TYPE_FIX_TERM"
        ["fixed_term"]=>
        int(90)
        ["fixed_begin_term"]=>
        int(0)
      }
      ["color"]=>
      string(7) "#63b359"
      ["notice"]=>
      string(30) "测试使用时请出示此券"
      ["service_phone"]=>
      string(11) "15311931577"
      ["description"]=>
      string(122) "测试不可与其他优惠同享
如需团购券发票,请在消费时向商户提出
店内均可使用,仅限堂食"
      ["source"]=>
      string(12) "造梦空间"
      ["location_id_list"]=>
      array(0) {
      }
      ["get_limit"]=>
      int(1)
      ["can_share"]=>
      bool(true)
      ["can_give_friend"]=>
      bool(false)
      ["use_custom_code"]=>
      bool(false)
      ["bind_openid"]=>
      bool(false)
      ["status"]=>
      string(21) "CARD_STATUS_VERIFY_OK"
      ["sku"]=>
      array(2) {
        ["quantity"]=>
        int(499999)
        ["total_quantity"]=>
        int(500000)
      }
      ["create_time"]=>
      int(1467025553)
      ["update_time"]=>
      int(1467025563)
      ["custom_url_name"]=>
      string(12) "立即使用"
      ["custom_url"]=>
      string(17) "http://www.qq.com"
      ["custom_url_sub_title"]=>
      string(14) "6个汉字tips"
      ["promotion_url"]=>
      string(17) "http://www.qq.com"
      ["promotion_url_name"]=>
      string(12) "更多优惠"
      ["center_title"]=>
      string(18) "顶部居中按钮"
      ["center_sub_title"]=>
      string(22) "按钮下方的wording"
      ["center_url"]=>
      string(17) "http://www.qq.com"
      ["area_code_list"]=>
      array(0) {
      }
    }
    ["deal_detail"]=>
    string(11) "deal_detail"
    ["advanced_info"]=>
    array(5) {
      ["time_limit"]=>
      array(0) {
      }
      ["text_image_list"]=>
      array(0) {
      }
      ["business_service"]=>
      array(0) {
      }
      ["consume_share_card_list"]=>
      array(0) {
      }
      ["share_friends"]=>
      bool(false)
    }
  }
}

string(66) "错误码:40073, 错误信息:invalid card id hint: [iAoZ0925ent3]"

$offset      = 0;
$count       = 5;
$status_list = 'CARD_STATUS_VERIFY_OK';

$WxApi = Api::factory('Card');
$ret = $WxApi->batchget($offset, $count, $status_list);

array(3) {
  ["card_id_list"]=>
  array(5) {
    [0]=>
    string(28) "pdkJ9uCAqQedZpqIEIucVDD5DYrQ"
    [1]=>
    string(28) "pdkJ9uDI9jmoPr3g_jP0SBJ29XzE"
    [2]=>
    string(28) "pdkJ9uFYOiKy6RzFt7WmKE1rbXoA"
    [3]=>
    string(28) "pdkJ9uNqoc5Edu0kthl1dAlsF3tY"
    [4]=>
    string(28) "pdkJ9uFO0_ewQpG7p4N3Tt-PDhj4"
  }
  ["total_num"]=>
  int(57)
  ["card_list"]=>
  array(0) {
  }
}

$card_id = 'pdkJ9uCzKWebwgNjxosee0ZuO3Os';

$type = 'groupon';

$base_info                         = [];
$base_info['logo_url']             = 'http://mmbiz.qpic.cn/mmbiz/2aJY6aCPatSeibYAyy7yct9zJXL9WsNVL4JdkTbBr184gNWS6nibcA75Hia9CqxicsqjYiaw2xuxYZiaibkmORS2oovdg/0';
$base_info['center_title']         = '顶部居中按钮';
$base_info['center_sub_title']     = '按钮下方的wording';
$base_info['center_url']           = 'http://www.baidu.com';
$base_info['custom_url_name']      = '立即使用';
$base_info['custom_url']           = 'http://www.qq.com';
$base_info['custom_url_sub_title'] = '6个汉字tips';
$base_info['promotion_url_name']   = '更多优惠';
$base_info['promotion_url']        = 'http://www.qq.com';

$WxApi = Api::factory('Card');
$ret = $WxApi->update($card_id, $type, $base_info);

$card_id = 'pdkJ9uLRSbnB3UFEjZAgUxAJrjeY';
$is_open = true;

$WxApi = Api::factory('Card');
$ret = $WxApi->paycellSet($card_id, $is_open);

string(74) "错误码:43017, 错误信息:

$card_id = 'pdkJ9uLRSbnB3UFEjZAgUxAJrjeY';
$stock   = 'increase'; //increase 增加   reduce 减少
$value   = 100;

$WxApi = Api::factory('Card');
$ret = $WxApi->modifystock($card_id, $stock, $value);

string(2) "ok"

string(68) "错误码:40073, 错误信息:invalid card id hint: [Sx3mrA0133ent3]"

$code     = '801192810944';
$new_code = '123456789101';
//$card_id  = 'pFS7Fjg8kV1IdDz01r4SQwMkuCKc';

$WxApi = Api::factory('Card');
$ret = $WxApi->codeUpdate($code, $new_code, $card_id);

string(2) "ok"

string(72) "错误码:40056, 错误信息:invalid serial code hint: [lvjija0435ent3]"

$card_id = 'pdkJ9uLRSbnB3UFEjZAgUxAJrjeY';

$WxApi = Api::factory('Card');
$ret = $WxApi->cardDelete($card_id);

string(2) "ok"

string(66) "错误码:40073, 错误信息:invalid card id hint: [1dLE0293ent3]"

$code    = '358962893266';
$card_id = '';

$WxApi = Api::factory('Card');
$ret = $WxApi->unavailable($code, $card_id);

string(2) "ok"

string(12) "缺少错误"

$begin_date  = '2015-12-01';
$end_date    = '2015-12-21';
$cond_source = 1; //卡券来源,0为公众平台创建的卡券数据、1是API创建的卡券数据

$WxApi = Api::factory('Card');
$ret = $WxApi->getcardbizuininfo($begin_date, $end_date, $cond_source);

array(2) {
  [0]=>
  array(17) {
    ["ref_date"]=>
    string(10) "2016-06-27"
    ["view_cnt"]=>
    int(1)
    ["view_user"]=>
    int(1)
    ["receive_cnt"]=>
    int(1)
    ["receive_user"]=>
    int(1)
    ["verify_cnt"]=>
    int(0)
    ["verify_user"]=>
    int(0)
    ["given_cnt"]=>
    int(0)
    ["given_user"]=>
    int(0)
    ["expire_cnt"]=>
    int(0)
    ["expire_user"]=>
    int(0)
    ["view_friends_cnt"]=>
    int(0)
    ["view_friends_user"]=>
    int(0)
    ["receive_friends_cnt"]=>
    int(0)
    ["receive_friends_user"]=>
    int(0)
    ["verify_friends_cnt"]=>
    int(0)
    ["verify_friends_user"]=>
    int(0)
  }
}

string(69) "错误码:61501, 错误信息:date range error hint: [0AkRta0797ube1]"

$begin_date  = '2016-06-20';
$end_date    = '2016-06-28';
$cond_source = 1; //卡券来源,0为公众平台创建的卡券数据、1是API创建的卡券数据
$card_id     = '';

$WxApi = Api::factory('Card');
$ret = $WxApi->getcardcardinfo($begin_date, $end_date, $cond_source, $card_id);

 array(3) {
  [0]=>
  array(17) {
    ["ref_date"]=>
    string(10) "2016-06-27"
    ["card_id"]=>
    string(28) "pdkJ9uLRSbnB3UFEjZAgUxAJrjeY"
    ["card_type"]=>
    int(1)
    ["is_pay"]=>
    int(0)
    ["view_cnt"]=>
    int(1)
    ["view_user"]=>
    int(1)
    ["receive_cnt"]=>
    int(1)
    ["receive_user"]=>
    int(1)
    ["verify_cnt"]=>
    int(0)
    ["verify_user"]=>
    int(0)
    ["given_cnt"]=>
    int(0)
    ["given_user"]=>
    int(0)
    ["expire_cnt"]=>
    int(0)
    ["expire_user"]=>
    int(0)
    ["verify_noself_cnt"]=>
    int(0)
    ["verify_noself_user"]=>
    int(0)
    ["isfriendscard"]=>
    int(0)
  }
}

string(69) "错误码:61501, 错误信息:date range error hint: [0AkRta0797ube1]"

$begin_date  = '2015-12-01';
$end_date    = '2015-12-21';
$cond_source = 1; //卡券来源,0为公众平台创建的卡券数据、1是API创建的卡券数据

$WxApi = Api::factory('Card');
$ret = $WxApi->getcardmembercardinfo($begin_date, $end_date, $cond_source);

{
   "list": [
       {
           "ref_date": "2015-06-23",
           "view_cnt": 0,
              "view_user": 0,
              "receive_cnt": 0,
              "receive_user": 0,
              "active_user": 0,
              "verify_cnt": 0,
              "verify_user": 0,
              "total_user": 86,
              "total_receive_user": 95
   ]
}

string(69) "错误码:61501, 错误信息:date range error hint: [feJ7ja0919re46]"

 $activate = [
       'membership_number' => '357898858', //会员卡编号,由开发者填入,作为序列号显示在用户的卡包里。可与Code码保持等值。
       'code' => '1231123', //创建会员卡时获取的初始code。
       'activate_begin_time' => '1397577600', //激活后的有效起始时间。若不填写默认以创建时的 data_info 为准。Unix时间戳格式
       'activate_end_time' => '1422724261', //激活后的有效截至时间。若不填写默认以创建时的 data_info 为准。Unix时间戳格式。
       'init_bonus' => '持白金会员卡到店消费,可享8折优惠。', //初始积分,不填为0。
       'init_balance' => '持白金会员卡到店消费,可享8折优惠。', //初始余额,不填为0。
       'init_custom_field_value1' => '白银', //创建时字段custom_field1定义类型的初始值,限制为4个汉字,12字节。
       'init_custom_field_value2' => '9折', //创建时字段custom_field2定义类型的初始值,限制为4个汉字,12字节。
       'init_custom_field_value3' => '200', //创建时字段custom_field3定义类型的初始值,限制为4个汉字,12字节。
 ];

$WxApi = Api::factory('Card');
$ret = $WxApi->activate($activate);

string(71) "错误码:40056, 错误信息:invalid serial code hint: [ccUd80760ent2]"

$card_id = 'pdkJ9uLRSbnB3UFEjZAgUxAJrjeY';

$ "USER_FORM_INFO_FLAG_MOBILE",
  "USER_FORM_INFO_FLAG_LOCATION",
  "USER_FORM_INFO_FLAG_BIRTHDAY",
];
$ield_list'] = ['喜欢的电影'];

$WxApi = Api::factory('Card');
$ret = $WxApi->activateuserform($card_id, $

string(156) "错误码:47001, 错误信息:data format error hint: [XiF6va0109ent1] Error before ":["USER_FORM_INFO_FLAG_EMAIL"],"custom_field_list":["喜欢的电影"]}"

$card_id = 'pbLatjtZ7v1BG_ZnTjbW85GYc_E8';
$code    = '916679873278';

$WxApi = Api::factory('Card');
$ret = $WxApi->membercardUserinfo($card_id, $code);

array(9) {
  ["openid"]=>
  string(28) "odkJ9uKRfgL2tclcoBpDX46wKswo"
  ["nickname"]=>
  string(9) "达尔文"
  ["membership_number"]=>
  string(12) "916679873278"
  ["bonus"]=>
  int(0)
  ["balance"]=>
  int(0)
  ["sex"]=>
  string(4) "MALE"
  ["user_info"]=>
  array(2) {
    ["common_field_list"]=>
    array(4) {
      [0]=>
      array(2) {
        ["name"]=>
        string(26) "USER_FORM_INFO_FLAG_MOBILE"
        ["value"]=>
        string(11) "13247668386"
      }
      [1]=>
      array(2) {
        ["name"]=>
        string(28) "USER_FORM_INFO_FLAG_LOCATION"
        ["value"]=>
        string(61) "广东省-广州市-海珠区-新港中路397号 TIT创意园"
      }
      [2]=>
      array(2) {
        ["name"]=>
        string(28) "USER_FORM_INFO_FLAG_BIRTHDAY"
        ["value"]=>
        string(9) "2015-4-30"
      }
      [3]=>
      array(2) {
        ["name"]=>
        string(25) "USER_FORM_INFO_FLAG_EMAIL"
        ["value"]=>
        string(15) "[email protected]"
      }
    }
    ["custom_field_list"]=>
    array(2) {
      [0]=>
      array(2) {
        ["name"]=>
        string(15) "喜欢的食物"
        ["value"]=>
        string(6) "公告"
      }
      [1]=>
      array(2) {
        ["name"]=>
        string(15) "喜欢的电影"
        ["value"]=>
        string(3) "bbn"
      }
    }
  }
  ["user_card_status"]=>
  string(6) "DELETE"
  ["has_active"]=>
  bool(true)
}

string(72) "错误码:40056, 错误信息:invalid serial code hint: [WPkBoA0556ent2]"

$updateuser = [
      'code' => '916679873278', //卡券Code码。
      'card_id' => 'pbLatjtZ7v1BG_ZnTjbW85GYc_E8', //卡券ID。
      'record_bonus' => '消费30元,获得3积分', //商家自定义积分消耗记录,不超过14个汉字。
      'bonus' => '100', //需要设置的积分全量值,传入的数值会直接显示,如果同时传入add_bonus和bonus,则前者无效。
      'balance' => '持白金会员卡到店消费,可享8折优惠。', //需要设置的余额全量值,传入的数值会直接显示,如果同时传入add_balance和balance,则前者无效。
      'record_balance' => '持白金会员卡到店消费,可享8折优惠。', //商家自定义金额消耗记录,不超过14个汉字。
      'custom_field_value1' => '100', //创建时字段custom_field1定义类型的最新数值,限制为4个汉字,12字节。
      'custom_field_value2' => '200', //创建时字段custom_field2定义类型的最新数值,限制为4个汉字,12字节。
      'custom_field_value3' => '300', //创建时字段custom_field3定义类型的最新数值,限制为4个汉字,12字节。
];

$WxApi = Api::factory('Card');
$ret = $WxApi->membercardUpdateuser($updateuser);

string(63) "错误码:40013, 错误信息:invalid appid hint: [OcL0736ent3]"

$WxApi = Api::factory('Card');
$ret = $WxApi->submerchant();

string(72) "错误码:52000, 错误信息:pic is not from cdn hint: [zk3JZa0670ent3]"

$WxApi = Api::factory('Card');
$ret = $WxApi->getapplyprotocol();
php
array(1) {
  [0]=>
  array(1) {
    ["primary_category_id"]=>
    int(1)
    ["category_name"]=>
    string(6) "美食"
    ["secondary_category"]=>
    array(1) {
      [0]=>
      array(5) {
        ["secondary_category_id"]=>
        int(101)
        ["category_name"]=>
        string(6) "粤菜"
        ["need_qualification_stuffs"]=>
        array(2) {
          [0]=>
          string(23) "food_service_license_id"
          [1]=>
          string(32) "food_service_license_bizmedia_id"
        }
        ["can_choose_prepaid_card"]=>
        int(1)
        ["can_choose_payment_card"]=>
        int(1)
      }
    }
  }
}
php
$name = 'TestGroup'; 

$WxApi = Api::factory('Groups');
$ret = $WxApi->create($name);
php
array(2) {
  ["id"]=>
  int(153)
  ["name"]=>
  string(9) "TestGroup"
}
php
$WxApi = Api::factory('Groups');
$ret = $WxApi->get();  //所有分组信息 如没有分组返回false.
php
array(2) {
  [0]=>
  array(3) {
    ["id"]=>
    int(2)
    ["name"]=>
    string(9) "星标组"
    ["count"]=>
    int(0)
  }
  [1]=>
  array(3) {
    ["id"]=>
    int(106)
    ["name"]=>
    string(9) "TestGroup"
    ["count"]=>
    int(0)
  }
}
php
$openid = 'odkJ9uE2f1BTY2rBKpFKvCcVoMvM';

$WxApi = Api::factory('Groups');
$ret = $WxApi->getid($openid);
php
int(2)
php
string(25) "参数错误,缺少Openid"
php
$id   = 100;
$name = 'testUpdate';

$WxApi = Api::factory('Groups');
$ret = $WxApi->update($id, $name);
php
string(62) "错误码:-1, 错误信息:system error hint: [.8_VXa0873vr23]"
php
$id = I('get.id', null, 'htmlspecialchars');

if (!is_numeric($id) || empty($id)) {
  return false;
}

$WxApi = Api::factory('Groups');
$ret = $WxApi->delete($id);
php
$openid     = 'odkJ9uEnEIJSNnr0Bk9_eA70ZS8o';
$to_groupid = 103; 

$WxApi = Api::factory('Groups');
$ret = $WxApi->moveUser($openid, $to_groupid);
php
string(67) "错误码:40003, 错误信息:invalid openid hint: [y9Cwta0422vr23]"
php
$openid_list = ['odkJ9uEnEIJSNnr0Bk9_eA70ZS8o', 'odkJ9uE2f1BTY2rBKpFKvCcVoMvM'];
$to_groupid  = 103;

$WxApi       = Api::factory('Groups');
$ret         = $WxApi->MoveUserlistGroup($openid_list, $to_groupid);
php
string(27) "参数必须为一个数组"
php
$WxApi = Api::factory('Kfaccount');

$kf_account = '009@DremQzone';
$nickname	= 'Maaahuanghuang';
$password	= '123456';

$ret = $WxApi->add($kf_account, $nickname, $password);
php
$WxApi = Api::factory('Kfaccount');

$kf_account = '009@DremQzone';
$nickname   = 'UaDD';
$password   = '654321';

$ret = $WxApi->update($kf_account, $nickname, $password);
php
array(3) {
  ["content"]=>
  string(73) "{
    "errcode": invalid kf_account,
    "errmsg": "invalid kf_account"
}"
  ["type"]=>
  string(25) "text/html; charset=gb2312"
  ["size"]=>
  string(2) "74"
}
php
$WxApi = Api::factory('Kfaccount');

$kf_account = '008@DremQzone';

$ret = $WxApi->del($kf_account);
php
string(48) "错误码:61452, 错误信息:invalid kf_account"
php
$WxApi = Api::factory('Kfaccount');
$ret = $WxApi->getkflist();
php

php
string(62) "错误码:-1, 错误信息:system error hint: [Ms_H3a0860vr22]"
php
$WxApi = Api::factory('Kfaccount');
$ret = $WxApi->getonlinekflist();
php

php
string(62) "错误码:-1, 错误信息:system error hint: [Ms_H3a0860vr22]"
php
$WxApi = Api::factory('Kfaccount');

$file       = 'Uploads/test.png';
$kf_account = '002@DremQzone';

$ret = $WxApi->uploadheadimg($file, $kf_account);
php

php
string(62) "错误码:-1, 错误信息:system error hint: [Ms_H3a0860vr22]"
php
$WxApi = Api::factory('Kfaccount');

$endtime   = '987654321';
$pageindex = '1';
$pagesize  = '10';
$starttime = '123456789';

$ret = $WxApi->getrecord($endtime, $pageindex, $pagesize, $starttime);
php

php
string(62) "错误码:-1, 错误信息:system error hint: [Ms_H3a0860vr22]"
php
$WxApi = Api::factory('Material');

//$type 获取素材类型, $offset 偏移 ,$count 数量 不能大于20	

$ret = $WxApi->batchget($type='image', 0, 20);
php
array(3) {
  ["item"]=>
  array(1) {
    [0]=>
    array(4) {
      ["media_id"]=>
      string(43) "9xQAI7XmtAaFkE6SrlfZKA4aLigUg0seur9VPnZ2V9U"
      ["name"]=>
      string(20) "api_mpnews_cover.jpg"
      ["update_time"]=>
      int(1450837760)
      ["url"]=>
      string(0) ""
    } 
  }
  ["total_count"]=>
  int(11)
  ["item_count"]=>
  int(12)
}
php
string(31) "参数错误,类型参数错误"
php
$WxApi = Api::factory('Material');

$data                          = [];
$data[0]['title']              = '标题';
$data[0]['thumb_media_id']     = 'b8lv6hmgqH9wcTS9VZ8wVPwjFlPXsLlgld8wUNd5uV8'; //图文消息的封面图片素材id(必须是永久mediaID)
$data[0]['author']             = '作者';
$data[0]['digest']             = '图文消息的摘要,仅有单图文消息才有摘要,多图文此处为空';
$data[0]['show_cover_pic']     = '1'; //是否显示封面,0为false,即不显示,1为true,即显示
$data[0]['content']            = '<p>图文消息的具体内容,支持HTML标签,必须少于2万字符,小于1M,且此处会去除JS</p>';
$data[0]['content_source_url'] = 'http://www.baidu.com';

$ret = $WxApi->addNews($data);
php
string(43) "BqvF0gQa9kd2v1kMl1pkHfKyWA8zcO96iHAYQs1H-Kw"
php
$WxApi = Api::factory('Material');

$file = 'Uploads/test.png';
$type = 'image';

//新增永久视频素材附加字段 (其他素材 此字段无效)
$info = ['title' => '视频素材的标题', 'introduction' => '视频素材的描述'];

$ret = $WxApi->add($file, $type, $info);
php
string(43) "BqvF0gQa9kd2v1kMl1pkHfKyWA8zcO96iHAYQs1H-Kw"
php
string(21) "文件路径不正确"
php
$WxApi = Api::factory('Material');

$media_id = 'ma2Rg8kmqPkObTlWWfxTX-mmAVOw0V51wBxTalWcmKg';

$ret = $WxApi->get($media_id);
php
array(3) {
  ["news_item"]=>
  array(1) {
    [0]=>
    array(9) {
      ["title"]=>
      string(6) "标题"
      ["author"]=>
      string(6) "作者"
      ["digest"]=>
      string(81) "图文消息的摘要,仅有单图文消息才有摘要,多图文此处为空"
      ["content"]=>
      string(112) "
图文消息的具体内容,支持HTML标签,必须少于2万字符,小于1M,且此处会去除JS

"
      ["content_source_url"]=>
      string(20) "http://www.baidu.com"
      ["thumb_media_id"]=>
      string(43) "b8lv6hmgqH9wcTS9VZ8wVPwjFlPXsLlgld8wUNd5uV8"
      ["show_cover_pic"]=>
      int(1)
      ["url"]=>
      string(107) "http://mp.weixin.qq.com/s?__biz=MzA5NTIxNjc1OA==&mid=501527430&idx=1&sn=693d51c15e22b46c913deb06da45dfe8#rd"
      ["thumb_url"]=>
      string(129) "http://mmbiz.qpic.cn/mmbiz/2aJY6aCPatQhicDS61u27u1wuHE6icQCfQVbMcrwnvz0gBIVHVNNbbclkvx11drqxue3wncEcE4YdYDGAF2v0vrw/0?wx_fmt=jpeg"
    }
  }
  ["create_time"]=>
  int(1467198008)
  ["update_time"]=>
  int(1467198008)
}
php
$WxApi = Api::factory('Material');

$media_id = 'ma2Rg8kmqPkObTlWWfxTX-mmAVOw0V51wBxTalWcmKg';

$ret = $WxApi->del($media_id);
php
$WxApi = Api::factory('Material');

$media_id = 'ma2Rg8kmqPkObTlWWfxTX9j_-BxI0tdyPrAhPMDDCAc';

$articles                       = [];
$articles['title']              = '标题-修改';
$articles['thumb_media_id']     = 'b8lv6hmgqH9wcTS9VZ8wVPwjFlPXsLlgld8wUNd5uV8'; //图文消息的封面图片素材id(必须是永久mediaID)
$articles['author']             = '作者';
$articles['digest']             = '图文消息的摘要,仅有单图文消息才有摘要,多图文此处为空';
$articles['show_cover_pic']     = '1'; //是否显示封面,0为false,即不显示,1为true,即显示
$articles['content']            = '<p>图文消息的具体内容,支持HTML标签,必须少于2万字符,小于1M,且此处会去除JS</p>';
$articles['content_source_url'] = 'http://www.baidu.com';

$index = 0;

$ret = $WxApi->updateNews($media_id, $articles, $index);
php
$WxApi = Api::factory('Material');
$ret   = $WxApi->getCount();
php
array(4) {
  ["voice_count"]=>
  int(0)
  ["video_count"]=>
  int(0)
  ["image_count"]=>
  int(11)
  ["news_count"]=>
  int(7)
}
php
$WxApi = Api::factory('Menu');

$button = new MenuItem("菜单");

$menus = array(
  new MenuItem("今日歌曲", 'click', 'V1001_TODAY_MUSIC'),
  $button->buttons(array(
    new MenuItem('搜索', 'view', 'http://www.soso.com/'),
    new MenuItem('视频', 'view', 'http://v.qq.com/'),
    new MenuItem('赞一下我们', 'click', 'V1001_GOOD'),
  )),
);

$ret = $WxApi->set($menus);
php
$WxApi = Api::factory('Menu');
$ret = $WxApi->get();
php
$WxApi = Api::factory('Menu');
$ret = $WxApi->current();
php

array(2) {
  ["is_menu_open"]=>
  int(1)
  ["selfmenu_info"]=>
  array(1) {
    ["button"]=>
    array(2) {
      [0]=>
      array(3) {
        ["type"]=>
        string(5) "click"
        ["name"]=>
        string(12) "今日歌曲"
        ["key"]=>
        string(17) "V1001_TODAY_MUSIC"
      }
      [1]=>
      array(2) {
        ["name"]=>
        string(6) "菜单"
        ["sub_button"]=>
        array(1) {
          ["list"]=>
          array(3) {
            [0]=>
            array(3) {
              ["type"]=>
              string(4) "view"
              ["name"]=>
              string(6) "搜索"
              ["url"]=>
              string(20) "http://www.soso.com/"
            }
            [1]=>
            array(3) {
              ["type"]=>
              string(4) "view"
              ["name"]=>
              string(6) "视频"
              ["url"]=>
              string(16) "http://v.qq.com/"
            }
            [2]=>
            array(3) {
              ["type"]=>
              string(5) "click"
              ["name"]=>
              string(15) "赞一下我们"
              ["key"]=>
              string(10) "V1001_GOOD"
            }
          }
        }
      }
    }
  }
}
php
$WxApi = Api::factory('Menu');
$ret = $WxApi->delete();
php
$WxApi = Api::factory('Qrcode');

$scene_id       = 1; //场景ID
$expire_seconds = 30; //有效期秒

$ret = $WxApi->create($scene_id, $expire_seconds);
php
array(3) {
  ["ticket"]=>
  string(96) "gQEK8ToAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL1RFT1VJVkRsQS1wNmJISVgtVzJ5AAIEgOJ0VwMEPAAAAA=="
  ["expire_seconds"]=>
  int(60)
  ["url"]=>
  string(43) "http://weixin.qq.com/q/TEOUIVDlA-p6bHIX-W2y"
}
php
$WxApi = Api::factory('Qrcode');

$scene_id = 2; //场景ID

$ret = $WxApi->createLimitInt($scene_id)
php
array(2) {
  ["ticket"]=>
  string(96) "gQGr7zoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL1JFUFY1dVhsV1BvaEZIakt2R195AAIE6jdqVgMEAAAAAA=="
  ["url"]=>
  string(43) "http://weixin.qq.com/q/REPV5uXlWPohFHjKvG_y"
}
php
$WxApi = Api::factory('Qrcode');

$queryStr = 'abc'; //场景ID

$ret = $WxApi->createLimitStr($queryStr);
php
array(2) {
  ["ticket"]=>
  string(96) "gQE58DoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL0trT01ZUlRsRi1wdUNCSmI1V3V5AAIEmzlqVgMEAAAAAA=="
  ["url"]=>
  string(43) "http://weixin.qq.com/q/KkOMYRTlF-puCBJb5Wuy"
}
php
$WxApi = Api::factory('Qrcode');

$ticket = 'gQE58DoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL0trT01ZU lRsRi1wdUNCSmI1V3V5AAIEmzlqVgMEAAAAAA=='; //场景ID

$ret = $WxApi->show($ticket);
php
$WxApi = Api::factory('Short');

$long_url = 'http://wap.koudaitong.com/v2/showcase/goods?alias=128wi9shh& spm=h56083&redirect_count=1'; 
$action   = 'long2short';

$ret = $WxApi->url($long_url, $action);
php
$WxApi = Api::factory('Short');
$ret = $WxApi->current();
php
string(55) "http://www.local-test.com/index.php/Home/Short/current"
php
$WxApi = Api::factory('Template');

$industry_id1   = '1'; 
$industry_id2   = '2';

$ret = $WxApi->apiSetIndustry($industry_id1, $industry_id2);
php
string(83) "错误码:43100, 错误信息:change template too frequently hint: [OLQx5a0823vr20]"
php
$WxApi = Api::factory('Template');
$template_id_short   = 'TM00015'; 
$ret = $WxApi->apiAddTemplate($template_id_short);
php
string(43) "sxi_AJ0pXpd6ngfLQ4bBasUVIsuN6YaG1Xc1dDxf7ps"
php
$WxApi = Api::factory('Template');
		
$touser = 'odkJ9uJ9qhdvV3SVjC5-n2roAv_s';
$template_id = 'sA7Z3V_REY7DXj5PeGExhVfCbiUz9PRhclaEaPmSlf4';
$url = 'http://www.baidu.com';
$data = array(
  'first'    => array('value' => '秒杀成功', 'color' => '#173177'),
  'keyword1' => array('value' => 'MacBook Pro', 'color' => '#173177'),
  'keyword2' => array('value' => '1元', 'color' => '#173177'),
  'remark'   => array('value' => '点击付款', 'color' => '#173177')
);

$ret = $WxApi->send($touser, $template_id, $url, $data);
php
int(407741624)
php
$WxApi = Api::factory('User');

$openid = 'odkJ9uE2f1BTY2rBKpFKvCcVoMvM';

$ret = $WxApi->getUserMsg($openid);
php
array(14) {
  ["subscribe"]=>
  int(1)
  ["openid"]=>
  string(28) "odkJ9uE2f1BTY2rBKpFKvCcVoMvM"
  ["nickname"]=>
  string(18) "阳光真美"
  ["sex"]=>
  int(2)
  ["language"]=>
  string(5) "zh_CN"
  ["city"]=>
  string(0) ""
  ["province"]=>
  string(0) ""
  ["country"]=>
  string(9) "安道尔"
  ["headimgurl"]=>
  string(117) "http://wx.qlogo.cn/mmopen/PiajxSqBRaELLTIXyb2g0ZshhJH8OWgIGDZVicOpSUmMIDZS0ZPcNBt38YaO9PB60KIgMCP1owxlG8V6TLUpvib2A/0"
  ["subscribe_time"]=>
  int(1444456066)
  ["unionid"]=>
  string(28) "oh8xHxB0f-Aftn141bMdTwfnEVAo"
  ["remark"]=>
  string(0) ""
  ["groupid"]=>
  int(0)
  ["tagid_list"]=>
  array(0) {
  }
}
php
string(67) "错误码:40003, 错误信息:invalid openid hint: [QHjQ5a0370vr18]"
php
array(2) {
  [0]=>
  array(14) {
    ["subscribe"]=>
    int(1)
    ["openid"]=>
    string(28) "odkJ9uDUz26RY-7DN1mxkznfo9xU"
    ["nickname"]=>
    string(3) "妞"
    ["sex"]=>
    int(2)
    ["language"]=>
    string(5) "zh_CN"
    ["city"]=>
    string(7) "Haidian"
    ["province"]=>
    string(7) "Beijing"
    ["country"]=>
    string(5) "China"
    ["headimgurl"]=>
    string(131) "http://wx.qlogo.cn/mmopen/R8p5f5Oic6pCGRXk7AmkBYXc9du3CibxicXluKzgzUeoCFnzs6Y74XjTibx3UywicGVzQibzHJkLo3npc5NU92SUn4SibsAh1nG5IsQ/0"
    ["subscribe_time"]=>
    int(1462877622)
    ["unionid"]=>
    string(28) "oh8xHxPKHoaW1pk8ArKJ5wMIVc-4"
    ["remark"]=>
    string(0) ""
    ["groupid"]=>
    int(0)
    ["tagid_list"]=>
    array(0) {
    }
  }
  [1]=>
  array(14) {
    ["subscribe"]=>
    int(1)
    ["openid"]=>
    string(28) "odkJ9uE2f1BTY2rBKpFKvCcVoMvM"
    ["nickname"]=>
    string(18) "阳光真美"
    ["sex"]=>
    int(2)
    ["language"]=>
    string(5) "zh_CN"
    ["city"]=>
    string(0) ""
    ["province"]=>
    string(0) ""
    ["country"]=>
    string(7) "Andorra"
    ["headimgurl"]=>
    string(117) "http://wx.qlogo.cn/mmopen/PiajxSqBRaELLTIXyb2g0ZshhJH8OWgIGDZVicOpSUmMIDZS0ZPcNBt38YaO9PB60KIgMCP1owxlG8V6TLUpvib2A/0"
    ["subscribe_time"]=>
    int(1444456066)
    ["unionid"]=>
    string(28) "oh8xHxB0f-Aftn141bMdTwfnEVAo"
    ["remark"]=>
    string(0) ""
    ["groupid"]=>
    int(0)
    ["tagid_list"]=>
    array(0) {
    }
  }
}