如何使用Twitter Direct Messages事件创建聊天窗口

时间:2019-05-12 11:35:13

标签: list kotlin twitter collections message

我在一个Android聊天应用程序上工作。我使用Twitter api。我得到用户直接消息作为事件。我想在Twitter Direct Messages Api事件响应中合并消息。

响应的数据结构具有sender_id和receive_id。我想做聊天窗口。我试图合并两个人之间的消息,但我不能。我该怎么办?

示例响应:

    "events": [
        {
            "type": "message_create",
            "id": "00000000000",
            "created_timestamp": "1557629578263",
            "message_create": {
                "target": {
                    "recipient_id": "00000000000"
                },
                "sender_id": "0000000",
                "source_app_id": "000000",
                "message_data": {
                    "text": "0000",
                    "entities": {
                        "hashtags": [
                            {
                                "text": "00000",
                                "indices": [
                                    0,
                                    6
                                ]
                            }
                        ],
                        "symbols": [],
                        "user_mentions": [],
                        "urls": []
                    }
                }
            }
        },
        {
            "type": "message_create",
            "id": "00",
            "created_timestamp": "1557576702974",
            "message_create": {
                "target": {
                    "recipient_id": "xxxx"
                },
                "sender_id": "yyyyy",
                "message_data": {
                    "text": ":D",
                    "entities": {
                        "hashtags": [],
                        "symbols": [],
                        "user_mentions": [],
                        "urls": []
                    }
                }
            }
        },
        {
            "type": "message_create",
            "id": "0000000",
            "created_timestamp": "1557576699106",
            "message_create": {
                "target": {
                    "recipient_id": "yy"
                },
                "sender_id": "xxx",
                "message_data": {
                    "text": "",
                    "entities": {
                        "hashtags": [],
                        "symbols": [],
                        "user_mentions": [],
                        "urls": []
                    }
                }
            }
        }
    ],
    "apps": {
        "aaa": {
            "id": "aaaa",
            "name": "Twitter Web Client",
            "url": "http://twitter.com"
        }
    }
}</i>```

0 个答案:

没有答案