Beispiel #1
0
def get_response_text(q_obj,text):
    rep_xml = u'''<xml>
    <ToUserName><![CDATA[%s]]></ToUserName>
    <FromUserName><![CDATA[%s]]></FromUserName>
    <CreateTime>%s</CreateTime>
    <MsgType><![CDATA[text]]></MsgType>
    <Content><![CDATA[%s]]></Content>
    </xml>''' %(q_obj['FromUserName'],q_obj['ToUserName'],TimeUtil.getIntTime(),text.content)
    return rep_xml.encode('UTF-8')
Beispiel #2
0
def get_response_music(q_obj,music):
    rep_xml = u'''<xml>
    <ToUserName><![CDATA[%s]]></ToUserName>
    <FromUserName><![CDATA[%s]]></FromUserName>
    <CreateTime>%s</CreateTime>
    <MsgType><![CDATA[music]]></MsgType>
    <Music>
    <Title><![CDATA[%s]]></Title>
    <Description><![CDATA[%s]]></Description>
    <MusicUrl><![CDATA[%s]]></MusicUrl>
    <HQMusicUrl><![CDATA[%s]]></HQMusicUrl>
    </Music>
    </xml>''' %(q_obj['FromUserName'],q_obj['ToUserName'],TimeUtil.getIntTime(),
                music.title,music.description,music.musicUrl,music.hqMusicUrl)
    return rep_xml.encode('UTF-8')
Beispiel #3
0
def get_response_news(q_obj,news_list):
    rep_xml = u'''<xml>
    <ToUserName><![CDATA[%s]]></ToUserName>
    <FromUserName><![CDATA[%s]]></FromUserName>
    <CreateTime>%s</CreateTime>
    <MsgType><![CDATA[news]]></MsgType>
    <ArticleCount>%d</ArticleCount>
    <Articles>''' %(q_obj['FromUserName'],q_obj['ToUserName'],TimeUtil.getIntTime(),len(news_list))

    for new in news_list:
        rep_xml += u'''<item>
        <Title><![CDATA[%s]]></Title>
        <Description><![CDATA[%s]]></Description>
        <PicUrl><![CDATA[%s]]></PicUrl>
        <Url><![CDATA[%s]]></Url>
        </item>''' %(new.title,new.brief,new.picUrl,new.url)#这里使用简介

    rep_xml += '</Articles></xml>' 
    return rep_xml.encode('UTF-8')