xdevplatform / open-evolution

Open evolution proposals for the Twitter API
https://twittercommunity.com/t/introducing-twitter-open-evolution/158770
41 stars 15 forks source link

Tweets don’t always found from direct messages #32

Open steven-douilliet opened 1 year ago

steven-douilliet commented 1 year ago

Context

Twitter API version : v2

Endpoint : GET /2/dm_events

Library : Tweepy library

I want to retrieve the tweets from direct messages sent by participants. Below my code :

tweepy.Paginator(
    client.get_direct_message_events,
    max_results=100,
    limit=3,
    expansions=[
        "sender_id", "referenced_tweets.id", "participant_ids"
    ],
    user_fields=[
        "id", "username", "name"
    ],
    dm_event_fields=[
        "id", "created_at", "dm_conversation_id", "attachments",
        "participant_ids", "sender_id", "referenced_tweets"
    ],
    tweet_fields=[
        "id", "author_id", "created_at", "entities"
    ]
)

The issue

I specify that the following issue is not present on Twitter API v1 (I checked).

When a participant sends a tweet link, it can be shows in two ways :

  1. The link is displayed and shows a preview (if not sensitve) and this is included as referenced tweet :
    {
    "dm_conversation_id": "123456789-987654321",
    "created_at": "2022-12-11T00:05:23.000Z",
    "referenced_tweets": [
        {
            "id": "160003..."
        }
    ],
    "sender_id": "123456789",
    "text": "(...) https://t.co/dl... (...)",
    "id": "160172982...",
    "event_type": "MessageCreate"
    }
  2. Sometimes the link is displayed twice and no tweet is found whereas a tweet URL is present:
    {
    "created_at": "2022-12-11T00:12:18.000Z",
    "id": "123456789",
    "text": "(...) https://t.co/Cq... https://t.co/7z... (...)",
    "sender_id": "133712...",
    "event_type": "MessageCreate",
    "dm_conversation_id": "123456789-987654321"
    }
igorbrigadir commented 1 year ago

Sometimes the link is displayed twice and no tweet is found whereas a tweet URL is present:

Just to clarify this via https://twittercommunity.com/t/tweets-dont-always-found-from-direct-messages/181433

A good example of this is when 2 tweet links are included. The referenced_tweets are empty, when the expected results are both linked tweets in referenced _tweets