Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Images from facebook API gives error "Bad URL date param"

I have thousands of images from facebook stored in my database. However recently I noticed that the images stored in the database are returning this error: "Bad URL date param"

It seems that we aren't supposed to store facebook images URL for a long time as they can expire.

My question is: how can I get the newer image URL from facebook API if the only information I have is the old image URL ? Maybe I could extract a specific data ID from the old URL, then query facebook API to get the new URL ?

Here's an example of an old (expired) URL :

https://scontent.xx.fbcdn.net/v/t1.0-9/15380747_1075074945947776_5898791779893134744_n.jpg?oh=7d445f227aa1922bebce375eae991a05&oe=597D1B48
like image 939
comdex Avatar asked Dec 02 '17 23:12

comdex


1 Answers

Ben commented already on your question with a potential duplicate around this topic: Facebook Image URL gets expired

I've stumbled across this as well and decided to download the images to our servers to avoid this situation. Anyway there is an alternative option.

In case you have the PPCA (Public Page Content Access) permission, you could try to grasp the node-id of the photo and fetch the most recent version through facebooks graph api.

https://scontent.xx.fbcdn.net/v/t1.0-9/15380747_1075074945947776_5898791779893134744_n.jpg?oh=7d445f227aa1922bebce375eae991a05&oe=597D1B48
                                                ^^^^^^^^^^^^^^^^

Which will lead to the following graph-query:

https://graph.facebook.com/v6.0/1075074945947776?fields=picture

Just tested it. In my case it gives me the most recent valid URL.

like image 160
Christoph Kluge Avatar answered Sep 17 '22 12:09

Christoph Kluge