fb-messenger-cli icon indicating copy to clipboard operation
fb-messenger-cli copied to clipboard

Added functionality to add attachments

Open p1ho opened this issue 5 years ago • 3 comments

Original Issue: #90

Added ability to attach file in cli

you can do >/a <absolute-path-to-file> (/attach works too) to upload a file to a thread.

image

Different file types are taken care of:

  • audio
  • video
  • image
  • file

if a file is not accepted by facebook, it will log a deny message.

How does this work?

This works by first uploading the file to https://upload.messenger.com/ajax/mercury/upload.php, if it succeeds with no errors, it will return a body with the id of the file you uploaded.

You can then append this id to the form data and POST it to https://www.messenger.com/messaging/send/ (the same endpoint where messages are sent)

Notes

  • If a file is not allowed (e.g., .exe files), it will log a denied message
  • Because of a bug with showing file attachments (even if it's sent by other people), it's harder to tell that this works, but if you open messenger in a browser, you can see that the files are uploaded correctly. #162
  • This does not address image copied in clipboard

p1ho avatar May 28 '19 04:05 p1ho

Hey @p1ho this is pretty cool! Sorry for the late reply, I'll give it a shot and hopefully FB didn't change their API too much so this still works

Alex-Rose avatar Aug 08 '19 02:08 Alex-Rose

Awesome! Excited to hear your feedback! I've also added a screenshot of it working above.

p1ho avatar Aug 08 '19 03:08 p1ho

@Alex-Rose Hello, just added a minor commit for the merge conflict. I just tested, the functionality still worked on my machine.

p1ho avatar Apr 15 '20 06:04 p1ho