php - file_get_contents give random older images from Facebook image profile -


i have simple php script, image facebook , download user profile image server.

  $url = 'https://graph.facebook.com/'.$iduser.'/picture?width=200&height=200&redirect=false';   $data = json_decode(file_get_contents($url), true);   $url = $data["data"]["url"];   $path = $iduser.'.jpg';   file_put_contents ($path, file_get_contents($url)); 

in cms site try open user profile page, time execute script, because want see actual user profile image. when user change user profile image script wrong. file_get_contents download old image, when refresh page or new image randomly. mean? error?

that still answer file_get_contents no caching?

but not work me(

> update:

facebook wrong me json link randomly

i ran code locally , got same problem. getting cached along line, added cache buster end of url, , forces new image.

$url = 'https://graph.facebook.com/'.$iduser.'/picture?width=200&height=200&redirect=false&' . time(); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -