linkedin-api icon indicating copy to clipboard operation
linkedin-api copied to clipboard

get_conversations

Open AchatY opened this issue 5 years ago • 5 comments

get_conversations return only the 20 first results .. I saw the documentation in https://linkedin.api-docs.io/v1.0/messaging/C5NLMQokSqdLZbcr8 and I see that there is an integer param createdBefore . But that doesn't work .. ? Can I have an example of something that work ?

Thank you

AchatY avatar Jun 21 '19 14:06 AchatY

nice find 👍 It's not implemented but would be very easy to do so! I'd be happy to walk you through necessary steps if you'd like to contribute

tomquirk avatar Jun 21 '19 20:06 tomquirk

Hello, Here's how I managed to do it and it works very well

def main():
    linkedin = Linkedin('email', 'password')
    conversations = linkedin.get_conversations()
    while len(conversations['elements']) > 0:
        if len(conversations['elements']) < 20:
            break
    else:
        conversations = linkedin.get_conversations(conversations['elements'][19]['events'][0]['createdAt'])

def get_conversations(self, createdBedore=None):
    """
    Return list of conversations the user is in.
    """
    params = {"keyVersion": "LEGACY_INBOX"}
    url = f"/messaging/conversations"
    if createdBedore:
        url = url + "?createdBefore=" + str(createdBedore)
    res = self._fetch(url, params=params)
    return res.json()

AchatY avatar Sep 24 '19 09:09 AchatY

Dose anyone find solution for this?

Tabish-Invo avatar Apr 24 '22 16:04 Tabish-Invo

@Tabish-Invo what's the problem with the solution above?

kenuxi avatar Dec 29 '22 14:12 kenuxi

if you copy and paste that it does not work, there is a very simple indentation error that once fixed for me worked on the main() function. The else statement should refer to the if therefore it has to be indented inside the while loop

manuelrech avatar Jan 12 '23 09:01 manuelrech