Exemplo n.º 1
0
<?php

$response = new stdClass();
if (!has_permission('manager feeds')) {
    $response->status = 'error';
    $response->message = '您没有权限进行此操作';
    echo json_encode($response);
    exit;
}
$openid = isset($_POST['openid']) ? strip_tags($_POST['openid']) : null;
$wechat_account = WechatAccount::findByOpenid($openid);
// check if the account exists
if ($wechat_account == null) {
    $response->status = 'error';
    $response->message = '此公众号不存在,无法退订';
    echo json_encode($response);
    exit;
}
// check if the user has subscribed the account
$user_wechat_account = UserWechatAccount::findByWechatAccountId($wechat_account->getId());
if (!$user_wechat_account) {
    $response->status = 'error';
    $response->message = '您并没有订阅此公众号,无法退订';
    echo json_encode($response);
    exit;
}
// unsubscribe
if ($user_wechat_account->delete()) {
    $response->status = 'success';
} else {
    $response->status = 'error';
Exemplo n.º 2
0
<div class="container" id="body">
<?php 
if ($articles) {
    foreach ($articles as $article) {
        $subscribed = false;
        if ($wechat_account = WechatAccount::findByOpenid($article['openid'])) {
            if (UserWechatAccount::findByWechatAccountId($wechat_account->getId())) {
                $subscribed = true;
            }
        }
        ?>
  <article class="row article">
    <div class="col-xs-12 content">
      <div class="inner">
        <div class="left">
          <img class="lazyloading" src="<?php 
        echo uri('modules/site/assets/images/ajax-loader-2.gif');
        ?>
" data-source="<?php 
        echo $article['thumb'];
        ?>
" />
        </div>
        <div class="middle">
          <?php 
        if (isset($article['title'])) {
            ?>
          <h2><?php 
            echo $article['title'];
            ?>
</h2>