Is it possible to use an uploaded file handle to upload to Facebook from the share dialog?

Viewed 132

I have a photo sharing web application and one of my requirements is to add a way to quickly share a photo to Facebook.

I have looked at several ways to do this, and the one I like the most is to get an OAuth access token and redirect back to my site. Once they select the image they want to share, I then launch the share dialog window in an iframe:

https://www.facebook.com/dialog/share?app_id=[MY_APP_ID]&display=iframe&href=https%3A%2F%2Fexample.com%2Fsomepic.jpg&access_token=[TOKEN_FROM_OAUTH]

This all works fine, except it shares a LINK to the picture and doesn't actually upload the image and store on Facebook.

So, my next thought was to use my access_token and create an upload session. So, I first create the session at this endpoint:

POST https://graph.facebook.com/app/uploads?access_token=[MY_OAUTH_ACCESS_TOKEN]&file_type=image/jpeg

That returns a session id for me as I expect. I then upload the file through this endpoint:

POST https://graph.facebook.com/[SESSION_ID_FROM_PREVIOUS_STEP]?is_reusable=true&file_length=[BYTES_OF_IMAGE]&data=[IMAGE_DATA_BYTES]

The above all seems to work, and it returns me a "File Handle". Something that looks like this:

4::aW1hZ2UvanBlZw==:ARaQWknagoLiMi1rE4wzsPLLKoWuwj0hpx8Wyv9p7VX0cMvZ0c5qTESqW1qyeb-ejM-BsoIaHcy1DfkEGZhAAaN-7ShSffoRDEZn1kK1IJ00bA:e:1632539894:100624633370919:533575686:ARZVnrjRFvfvQcEYvbw

Now to the point of my question. Is it at all possible to somehow pass the above file handle to the dialog share iframe as opposed to passing it a URL? Something like this:

https://www.facebook.com/dialog/share?app_id=[MY_APP_ID]&display=iframe&attachment_id=4::aW1hZ2UvanBlZw==:ARaQWknagoLiMi1rE4wzsPLLKoWuwj0hpx8Wyv9p7VX0cMvZ0c5qTESqW1qyeb-ejM-BsoIaHcy1DfkEGZhAAaN-7ShSffoRDEZn1kK1IJ00bA:e:1632539894:100624633370919:533575686:ARZVnrjRFvfvQcEYvbw&access_token=[TOKEN_FROM_OAUTH]

I know that attachment_id doesn't work, but is there another way to do this?

It may not be possible, but would make it a cleaner solution that having a link to the images, which may end up changing...

Thanks!

0 Answers
Related