<commit_before><?php
/**
 * Widget Framework
 *
 * @copyright   <NAME>
 * @license     http://www.opensource.org/licenses/apache2.0.php Apache License
 */

namespace Widget;

/**
 * The widget for WeChat(Weixin) callback message
 *
 * @author      <NAME> <<EMAIL>>
 * @link        http://mp.weixin.qq.com/wiki/index.php?title=%E6%B6%88%E6%81%AF%E6%8E%A5%E5%8F%A3%E6%8C%87%E5%8D%97
 */
class Callback extends AbstractWidget
{
    /**
     * Callback接口的验证token
     * 
     * @var string
     */
    protected $token;
    
    /**
     * 用户输入的数据
     * 
     * @var string
     */
    protected $input;
    
    /**
     * 开发者微信号
     * 
     * @var string
     */
    protected $to;
    
    /**
     * 发送方帐号（一个OpenID）
     * 
     * @var string
     */
    protected $from;
    
    protected $postData = ' <xml>
        <ToUserName><![CDATA[toUser]]></ToUserName>
        <FromUserName><![CDATA[fromUser]]></FromUserName> 
        <CreateTime>1348831860</CreateTime>
        <MsgType><![CDATA[text]]></MsgType>
        <Content><![CDATA[Hello2BizUser]]></Content>
        <MsgId>1234567890123456</MsgId>
        </xml>';
    
    protected $rules = array();
    
    protected $fallback;
    
    /**
     * 构造器
     * 
     * @param array $options 配置选项
     */
    public function __construct($options = array())
    {
        parent::__construct($options);
        
        // 校验请求是否来自微信服务器
        $echostr = $this->query('echostr');
        if ($this->checkSignature()) {
            echo $this->escape($echostr);
        } else {
            return $this->response('404');
            exit('access deny');
        }
        
        // 解析用户输入
        $this->parseInput();
    }
    
    /**
     * 获取用户发送的文本信息
     * 
     * @return string
     */
    public function getIntput()
    {
        return $this->input;
    }
    
    protected function parseInput()
    {<commit_msg>added getFrom, getTo method to recive user ids<commit_after><?php
/**
 * Widget Framework
 *
 * @copyright   <NAME>
 * @license     http://www.opensource.org/licenses/apache2.0.php Apache License
 */

namespace Widget;

/**
 * The widget for WeChat(Weixin) callback message
 *
 * @author      <NAME> <<EMAIL>>
 * @link        http://mp.weixin.qq.com/wiki/index.php?title=%E6%B6%88%E6%81%AF%E6%8E%A5%E5%8F%A3%E6%8C%87%E5%8D%97
 */
class Callback extends AbstractWidget
{
    /**
     * Callback接口的验证token
     * 
     * @var string
     */
    protected $token;
    
    /**
     * 用户输入的数据
     * 
     * @var string
     */
    protected $input;
    
    /**
     * 开发者微信号
     * 
     * @var string
     */
    protected $to;
    
    /**
     * 发送方帐号（一个OpenID）
     * 
     * @var string
     */
    protected $from;
    
    protected $postData = ' <xml>
        <ToUserName><![CDATA[toUser]]></ToUserName>
        <FromUserName><![CDATA[fromUser]]></FromUserName> 
        <CreateTime>1348831860</CreateTime>
        <MsgType><![CDATA[text]]></MsgType>
        <Content><![CDATA[Hello2BizUser]]></Content>
        <MsgId>1234567890123456</MsgId>
        </xml>';
    
    /**
     * 自定回复的消息规则
     * 
     * @var array
     */
    protected $rules = array();
    
    /**
     *
     * @var string
     * @todo 更改更合适的名称
     */
    protected $fallback;
    
    /**
     * 构造器
     * 
     * @param array $options 配置选项
     */
    public function __construct($options = array())
    {
        parent::__construct($options);
        
        // 校验请求是否来自微信服务器
        $echostr = $this->query('echostr');
        if ($this->checkSignature()) {
            echo $this->escape($echostr);
        } else {
            return $this->response('404');
            exit('access deny');
        }
        
        // 解析用户输入
        $this->parseInput();
    }
    
    /**
     * 获取用户发送的文本信息
     * 
     * @return string
     */
    public function getIntput()
    {
        return $this->input;
    }
    
    /**
     * Reurns a user OpenID who send message to you
     * 
     * @return string
     */
    public function getFrom()
    {
        return $this->from;
    }
    
    /**
     * Returns your id
     * 
     * @return string
     */
    public function getTo()
    {
        return $this->to;
    }
    
    protected function parseInput()
    {
{'fraction_non_alphanumeric': 0.1509790044821892, 'fraction_numerical': 0.025005897617362584, 'mean_word_length': 1.7075351213282248, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1037511', 'n_tokens_mistral': 1568, 'n_tokens_neox': 1539, 'n_words': 232}