Beispiel #1
0
 function refresh_js_token($ctx)
 {
     $id = intval($_GET['id']);
     $account = WxAccount::get($id);
     $account->refresh_js_token();
     _redirect(_list_url());
 }
Beispiel #2
0
 function init($ctx)
 {
     parent::init($ctx);
     $account = WxAccount::get(1);
     // 1 是"懒投资"服务号
     $this->appid = $account->app_id;
     $this->secret = $account->app_secret;
 }
Beispiel #3
0
 function sign($url)
 {
     $noncestr = WxAccount::generate_randstr();
     $timestamp = time();
     $js_token = $this->js_token();
     $data = array('jsapi_ticket=' . $js_token, 'noncestr=' . $noncestr, 'timestamp=' . $timestamp, 'url=' . $url);
     $sign = sha1(implode('&', $data));
     return array('noncestr' => $noncestr, 'timestamp' => $timestamp, 'sign' => $sign);
 }
Beispiel #4
0
 private function unsubscribe($xml)
 {
     $from = $xml->FromUserName;
     $to = $xml->ToUserName;
     $connect = WxConnect::get_by('wx_openid', $from);
     if ($connect) {
         $connect->update(array('wx_subscribe' => WxConnect::WX_UNSUBSCRIBED, 'prj_subscribe' => WxConnect::PRJ_UNSUBSCRIBED));
     }
     /* START 增加逻辑,订阅后,尝试向wx_openids插入 add@2015-04-20 21:49:12 */
     try {
         $uid = isset($connect->user_id) ? $connect->user_id : '';
         $uid_txt = $uid ? "用户id {$uid}" : '';
         $tmp_where = "wx_openid = '{$from}' and wx_id = '{$to}'";
         $wx_account_info = WxAccount::get_by('wx_id', $to);
         $wx_openid_info = WxOpenid::find_one($tmp_where);
         if ($wx_openid_info && $wx_openid_info->status == WxOpenid::STATUS_YES) {
             $attrs = array('status' => WxOpenid::STATUS_NO);
             $ret = $wx_openid_info->update($attrs);
             Logger::info("粉丝取消关注事件, 微信订阅服务号处理, 更新微信粉丝openid状态为[未关注], 微信openid : {$from} ,服务号微信id {$to} {$uid_txt}");
         }
     } catch (Exception $e) {
         Logger::error("粉丝取消关注事件, 微信订阅服务号处理, 处理微信粉丝openid发生错误, 微信openid : {$from} ,服务号微信id {$to} {$uid_txt} 异常信息 - " . $e);
     }
     /* -- END -- */
     Logger::info($connect->user_id . "取消关注微信公众号");
 }
Beispiel #5
0
?>
</td>
	</tr>
	<tr>
		<td>状态</td>
		<td>
			<?php 
echo Html::select('f[status]', array('' => '') + WxAccount::status_table(), $m->status);
?>
		</td>
	</tr>
	<tr>
		<td>类型</td>
		<td>
			<?php 
echo Html::select('f[type]', array('' => '') + WxAccount::type_table(), $m->type);
?>
		</td>
	</tr>
	<tr>
		<td>原始ID(*)</td>
		<td>
			<input class="form-control" type="text" name="f[wx_id]" value="<?php 
echo $m->wx_id;
?>
" />
		</td>
	</tr>
	<tr>
		<td>Token(*)</td>
		<td>
Beispiel #6
0
 function push($ctx)
 {
     try {
         $aid = $_POST['aid'] ? intval($_POST['aid']) : 0;
         $account = WxAccount::get($aid);
         $wx_menu = new WxMenu($account);
         $ret = $wx_menu->create($account->menu);
         $response = array('succ' => 1, 'msg' => '操作成功');
     } catch (Exception $e) {
         $msg = $e->getMessage();
         $msg = !empty($msg) ? $msg : '操作失败';
         $response = array('succ' => 0, 'msg' => $msg);
     }
     echo json_encode($response);
     $this->layout = false;
 }