Example #1
0
 public function __toString()
 {
     $responseObj = null;
     $responseObj = new TextResponse($this->fromUserName, $this->toUserName, $this->msg);
     global $log;
     $log->record($responseObj->__toString());
     return $responseObj->__toString();
 }
 /**
  * withContent
  *
  * @param   mixed $content
  *
  * @return  static
  * @throws \InvalidArgumentException
  */
 public function withContent($content)
 {
     return parent::withContent($this->encode($content));
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTextResponses()
 {
     return $this->hasMany(TextResponse::className(), ['TextBox_id' => 'id']);
 }
Example #4
0
    case 'link':
        break;
    default:
        echo htmlspecialchars($_GET['echostr']);
        exit;
}
$response_id = intval($response_id);
//根据response_id进行响应
if (0 < $response_id) {
    $get_response = 'select `msgType`,`content`,`title`,`description`,`musicUrl`,`HQMusicUrl`,`url`,`picUrl`,`mediaId`,`thumbMediaId` from ';
    $get_response .= $db->table('wx_response') . ' where `id`=' . $response_id;
    $response_rule = $db->fetchRow($get_response);
    switch ($response_rule['msgType']) {
        case 'text':
            //文本信息回复
            $responseObj = new TextResponse($public_account, $openid, $response_rule['content']);
            $response = $responseObj->__toString();
            break;
        case 'news':
            //图文信息回复
            $title = unserialize($response_rule['title']);
            $description = unserialize($response_rule['description']);
            $picUrl = unserialize($response_rule['picUrl']);
            $url = unserialize($response_rule['url']);
            $items = array();
            foreach ($title as $key => $value) {
                $items[] = array('title' => $value, 'description' => $description[$key], 'picUrl' => $picUrl[$key], 'url' => $url[$key]);
            }
            $responseObj = new NewsResponse($public_account, $openid, $items);
            $response = $responseObj->__toString();
            break;
 /**
  * Constructor.
  *
  * @param  string  $xml      The XML body data.
  * @param  int     $status   The status code.
  * @param  array   $headers  The custom headers.
  */
 public function __construct($xml = '', $status = 200, array $headers = array())
 {
     parent::__construct($this->toString($xml), $status, $headers);
 }
Example #6
0
 public function __toString()
 {
     $responseObj = null;
     $responseObj = new TextResponse($this->fromUserName, $this->toUserName, $this->msg);
     return $responseObj->__toString();
 }
Example #7
0
 public function testContentTypeIsSetableViaConstructor()
 {
     $response = new TextResponse('sometext', 'html');
     $headers = $response->getHeaders();
     $this->assertEquals('text/html', $headers['Content-type']);
 }