Facebook API Direct Messages Image Expired - How do I get a new image? URL expiration

I help maintain an app that integrates with Facebook and has many archived links to old private messages. Sometimes these images expire and we go to facebook and request a new image. This works 90% of the time.

In about 10% of cases, we return a response that we cannot determine what the new image is.

How can I request a new URL for an expired Facebook private message, preferably using v2.5 or later of the Graph API?

We are currently making a GET request to the Facebook Graph API using the post id of the private message, for example:

https://graph.facebook.com/v2.3/m_mid.XXXXXXXXX:YYYYYYYYY

and that gives us an answer that has a bunch of attachments

. For 90% of use cases, there is a new attachment with a field url

or name

with a new filename that contains the old filename, eg. old file name XXX, we will see the new file name like .... XXXX .... in the field url

.

attachments [url='*%s*']/image_data/url
attachments [name='*%s*']/image_data/url

      

or sometimes

picture

      

but this is not what we are getting now, which is a bunch of attachments without the possibility of matching with a new image.

+3


source to share


1 answer


We were unable to find a way for the graph API, but you have the following solutions that we are considering:



  • When there is only one attachment in the response, we just use that URL. This works for a while, but fails when there is more than one image, of course.

  • Save more metadata about the image, in the worst case MD5 file. Then compare that to MD5 with other files until we get the one we want. Instead of MD5, we could consider using the file information from the HEAD request. All of this is untested.

  • Update our old post metadata with new metadata whenever this happens, thereby avoiding the problem entirely as new image requests will come from the new metadata.

0


source







All Articles