zoukankan      html  css  js  c++  java
  • List User Messages:列出用户消息

    List User Messages:列出用户消息:
    
    
    curl -H 'Authorization: Token 0ac9e8585ef6ae51eb62c785d10a6c5102de3ff7' "http://127.0.0.1:8000/api2/user/msgs/2/"
    
    
    
    curl -d "message=this is a user msg reply from Scan" -H 'Authorization: Token 0ac9e8585ef6ae51eb62c785d10a6c5102de3ff7' "http://192.168.137.1:8000/api2/user/msgs/015208@zjtlcb.com/"
    
    
    
    [root@node0H 'Authorization: Token 0ac9e8585ef6ae51eb62c785d10a6c5102de3ff7' "http://192.168.137.1:8000/api2/user/msgs/015208@zjtlcb.com/"
    {"to_email": "015208@zjtlcb.com", "next_page": -1, "msgs": [{"attachments": [], "timestamp": 1503313050, "from_email": "99999@zjtlcb.com", "msgid": 3, "msg": "this is a user msg reply from Scan", "nickname": "99999"}, {"attachments": [], "timestamp": 1503313045, "from_email": "99999@zjtlcb.com", "msgid": 2, "msg": "this is a user msg reply from u8d75u6768u5065", "nickname": "99999"}, {"attachments": [], "timestamp": 1503313014, "from_email": "99999@zjtlcb.com", "msgid": 1, "msg": "this is a user msg reply from Scan", "nickname": "99999"}]}[root@node01 ~]# 
    
    def list_user_messages():
        token = gettoken()
        print len(token)
        token = 'Token' + ' ' + token
        print token
        url = 'http://192.168.137.1:8000/api2/user/msgs/015208@zjtlcb.com/'
        conn = httplib.HTTPConnection('127.0.0.1', 8000)
        headers = {"Authorization": token, "Accept": "application/json; indent=10", "content-type": "application/json"}
        print headers
        conn.request('GET', url, '', headers)
        response = conn.getresponse()
        res = response.read()
        print res
    if __name__ == '__main__':
        list_user_messages()
    
    C:Python27python.exe C:/Users/TLCB/PycharmProjects/untitled/mycompany/a8.py
    {"token": "0ac9e8585ef6ae51eb62c785d10a6c5102de3ff7"}
    <type 'str'>
    <type 'dict'>
    0ac9e8585ef6ae51eb62c785d10a6c5102de3ff7
    40
    Token 0ac9e8585ef6ae51eb62c785d10a6c5102de3ff7
    {'content-type': 'application/json', 'Accept': 'application/json; indent=10', 'Authorization': u'Token 0ac9e8585ef6ae51eb62c785d10a6c5102de3ff7'}
    {
            "to_email": "015208@zjtlcb.com",
            "next_page": -1,
            "msgs": [
                    {
                            "attachments": [],
                            "timestamp": 1503313050,
                            "from_email": "99999@zjtlcb.com",
                            "msgid": 3,
                            "msg": "this is a user msg reply from Scan",
                            "nickname": "99999"
                    },
                    {
                            "attachments": [],
                            "timestamp": 1503313045,
                            "from_email": "99999@zjtlcb.com",
                            "msgid": 2,
                            "msg": "this is a user msg reply from u8d75u6768u5065",
                            "nickname": "99999"
                    },
                    {
                            "attachments": [],
                            "timestamp": 1503313014,
                            "from_email": "99999@zjtlcb.com",
                            "msgid": 1,
                            "msg": "this is a user msg reply from Scan",
                            "nickname": "99999"
                    }
            ]
    }
    
    Process finished with exit code 0
    

  • 相关阅读:
    遍历一个枚举类型
    ASP.NET:C#中时间格式的转换
    DataAdapter去批量更新数据的FAQ
    .Net/C#: 实现支持断点续传多线程下载的 Http Web 客户端工具类 (第2版) (C# DIY HttpWebClient) 收藏
    如何使数据库中取出的数据保持原有格式
    如何获取控制台应用程序自己的文件名
    2008将倒掉一大部分的工厂和贸易公司
    组六对半分组组合投资方案(36789)
    重又归孑然一身
    善于总结
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349576.html
Copyright © 2011-2022 走看看