<?php
namespace Common\Vendor;

class JMessage{
    public function __construct($appKey = '', $masterSecret = ''){
        $push_info = M("PushSet")->find();
        $appKey = $push_info['appkey'];
        $masterSecret = $push_info['master_secret'];        
        $jm = new \Common\Vendor\JMessage\JMessage($appKey, $masterSecret);
        $this->message = new \Common\Vendor\JMessage\IM\Message($jm);
    }
    public function sendText($to,$msg='',$target='single',$from=''){
        $return=array('status'=>0,'info'=>'');
        if(empty($from) || !is_array($from))$from = array('id'=>'admin','type'=>'admin');        
        $target = array('id'   => $to, 'type' => $target);
        $msg =array('text' => $msg);       
        $response = $this->message->sendText(1, $from, $target, $msg);
    }

}