Subscribe.class.php 1.87 KB
<?php
/**
 * 应用订阅
 * 
 * @name Controller_Subscribe
 * @package controller
 * @copyright yoho.inc
 * @version 5.0 (2014-02-08 15:42:53)
 * @author fei.hong <fei.hong@yoho.cn>
 */
class Controller_Subscribe extends Controller_Abstract
{
    /**
     * 修改订阅
     * 
     * @param integer key  应用的ID
     * @param string sign 通过应用颁发的密钥所生成的签名
     * @param string new_secret  新的颁发密钥<optional>
     * @param string scope  新的订阅信息<optional>
     * @return json
     */
    public function indexAction()
    {
        $result = null;
        
        if (isset($this->_appId))
        {
            $newSecret = $this->_request->post('new_key', null);
            $scope = $this->_request->post('scope', null);
            
            $result = Facade_Subscribe::upd($this->_appId, $newSecret, null, $scope, null);
            if ($result)
            {
                return $this->returnJson(Config_Code::$success['system']['code'], $result, Config_Code::$success['system']['message']);
            }
        }
        
        return $this->returnJson(Config_Code::$error['system']['code'], $result, Config_Code::$error['system']['message']);
    }

    /**
     * @todo test interface
     */
    public function testAction()
    {
        return;
        
        $test = Facade_Subscribe::add(null, null, 'YOHOSHOW', 'uid,nick,gender,age,birthday,email,mobile_phone,real_name,head_pic', 1);
        $test = Facade_Subscribe::add(null, null, 'YOHOBUY', 'uid,nick,gender,age,birthday,email,mobile_phone,real_name,head_pic', 1);
        
        $test = Facade_Subscribe::upd('1392109210', '6714d55f23339880cd04150f102f80c6', md5('#@!@#$%^yoho'.mt_rand()), null, 'uid,nick,gender,head_pic', null);
        $test = Facade_Subscribe::upd('1392109259', '0145ed50917f396584bb78ce36ec70d1', null, null, 'uid,nick,gender,email,head_pic', 0);
    }

}