protected function sendNewsMsgToJsonString(WxSendNewsMsg $msg)
    {
        $itemArray  = $msg->getAllArticleItems();
        $itemStr    = '';
        foreach ($itemArray as $item) {
            $itemStr .= $this->sendNewsItemToJsonString($item) . ',';
        }

        $itemStr    = substr($itemStr, 0, -1);

        $formatStr = '{
                        "touser":"%s",
                        "msgtype":"%s",
                        "news":{
                            "articles": [
                             %s
                             ]
                        }
                    }';

        $result = sprintf($formatStr,   $msg->getToUserName(),
                                        $msg->getMsgType(),
                                        $itemStr
                            );

        return $result;
    }
protected function sendNewsMsgToJsonString(WxSendNewsMsg $msg)
    {
        $itemArray  = $msg->getAllArticleItems();
        $itemStr    = '';
        foreach ($itemArray as $item) {
            $itemStr .= $this->sendNewsItemToJsonString($item) . ',';
        }

        $itemStr    = substr($itemStr, 0, -1);

        $formatStr = '{
                        "touser":"%s",
                        "msgtype":"%s",
                        "news":{
                            "articles": [
                             %s
                             ]
                        }
                    }';

        $result = sprintf($formatStr,   $msg->getToUserName(),
                                        $msg->getMsgType(),
                                        $itemStr
                            );

        return $result;
    }
protected function sendNewsMsgToJsonString ( WxSendNewsMsg $ msg ) { $ itemArray = $ msg -> getAllArticleItems ( ) ; $ itemStr = '' ; foreach ( $ itemArray as $ item ) { $ itemStr .= $ this -> sendNewsItemToJsonString ( $ item ) . ',' ; } $ itemStr = substr ( $ itemStr , 0 , - 1 ) ; $ formatStr = '{
                        "touser":"%s",
                        "msgtype":"%s",
                        "news":{
                            "articles": [
                             %s
                             ]
                        }
                    }' ; $ result = sprintf ( $ formatStr , $ msg -> getToUserName ( ) , $ msg -> getMsgType ( ) , $ itemStr ) ; return $ result ; }
formatter WxSendNewsMsg to Json string
@param WxSendNewsMsg $msg
@return string
formatter WxSendNewsMsg to Json string