Example #1
0
 function __construct()
 {
     global $_W;
     $user_agent = $_SERVER['HTTP_USER_AGENT'];
     if (strpos($user_agent, 'MicroMessenger') === true) {
         $openid = $_W['fans']['from_user'];
         if (empty($openid)) {
             $this->pub_fans = o2::getOuser();
             if (empty($this->pub_fans['openid'])) {
                 message('获取信息失败,请确保是认证服务号或者借用授权的AppId和AppSecret正确');
             }
             $fans = pdo_fetch('SELECT * FROM' . tablename('fans') . " WHERE weid = :weid AND from_user = :from_user", array(':weid' => $_W['weid'], ':from_user' => $this->pub_fans['openid']));
             $user = array('nickname' => emoji_unified_to_html($this->pub_fans['nickname']), 'gender' => $this->pub_fans['sex'], 'residecity' => $this->pub_fans['city'], 'resideprovince' => $this->pub_fans['province'], 'nationality' => $this->pub_fans['country'], 'avatar' => $this->pub_fans['headimgurl']);
             if (empty($fans)) {
                 $user['createtime'] = TIMESTAMP;
                 $user['weid'] = $_W['weid'];
                 $user['from_user'] = $this->pub_fans['openid'];
                 pdo_insert('fans', $user);
             } else {
                 pdo_update('fans', $user, array('weid' => $_W['weid'], 'from_user' => $this->pub_fans['openid']));
             }
         } else {
             $this->pub_fans = o2::getFans($openid);
         }
     }
     //print_r($this->pub_fans);
     //exit();
 }
Example #2
0
 public function doMobileEntry()
 {
     global $_W, $_GPC;
     /*$data = array('first'=>array('value'=>urlencode('测试'),'color'=>'#FF0000'),
     			'keyword1'=>array('value'=>urlencode('测试'),'color'=>'#FF0000'),
     			'keyword2'=>array('value'=>urlencode('测试'),'color'=>'#FF0000'),
     			'remark'=>array('value'=>urlencode('测试'),'color'=>'#FF0000'),
     			);
     		$content =  $this->createTplData($data,'o8QDijihhQFMFPd-t1ruryFuVr4k','sUiz5Dd2l-LBgAxrs1XmqlaZn1ZrjerIg9Xfm2Kw7iU','www.jiaduiguo.net');
     		$callback =  o2::tplMsg($content);
     		print_r($callback);
     		exit();*/
     $user = o2::getOuser();
     print_r($user);
     exit;
     /*require_once IA_ROOT.'/source/modules/oauth2/o2.php';
     		require_once IA_ROOT.'/source/modules/oauth2/emoji.php';
     		$user = o2::getOuser();*/
 }