18

I have an issue now, suddenly all url image from facebook graph API in my database return a default image look likes this:

enter image description here

Example url :

http://graph.facebook.com/{user-id}/picture?type=large

Matheus Cuba
  • 2,068
  • 1
  • 20
  • 31
itx
  • 1,327
  • 1
  • 15
  • 38

3 Answers3

17

It is a known bug (which could also mean that it will not be possible anymore in the future):

You should subscribe to the bugs and wait.

Update: You can make it work by adding an access_token to the API call, but you should only do that server side, of course. An App Access Token should be good enough:

https://graph.facebook.com/<userId>/?fields=picture&type=large&access_token=...

Update 20.04.2018: It seems like picture URLs are working without an Access Token again: <img src="https://graph.facebook.com/[app-scoped-id]/picture" />

andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • 1
    FB has cracked down on a lot of Graph API related stuff lately. I guess this isn't a bug. – AmazingDreams Apr 19 '18 at 14:58
  • yeah, i assume that it will stay that way, with the need to use a token. it´s not a bad thing though imho. people just need to be careful with tokens, i hope they don´t hardcode them in client code. – andyrandy Apr 19 '18 at 15:00
  • 2
    This makes displaying a user's avatar on pages much more problematic (and demanding), because you cannot just slap the access token for each avatar on the public html dished out. Before, there was a semi-static url that always showed the *current avatar of that fb user*. I guess now we need to constantly scrape facebook with a cronjob behind the scenes and locally store the current avatar of every single user (we have about 154,000+- facebook linked users). Wonderful. I guess we will just tell our users "sorry, no more fb avatars!" – IncredibleHat Apr 19 '18 at 15:03
  • 1
    @IncredibleHat you could create a proxy that retrieves avatars on request keeping the access token secret and caches results for some time – AmazingDreams Apr 19 '18 at 15:16
  • the original report could still be helpfull to see a relation: https://developers.facebook.com/bugs/185053568795519/ – Martin Schneider Apr 19 '18 at 16:31
  • Yeah, @AmazingDreams ... I just built one. Small script which digs up the users token from the db, sticks it on the url, then pipes it out with image headers. Ran into new issues now with so many user's tokens have expired (60 day lifetime) because they have not done a login event recently. – IncredibleHat Apr 19 '18 at 16:54
  • in that case, you should not be allowed to access their picture or any data anyway. i guess that is the reason for the change. – andyrandy Apr 19 '18 at 17:06
  • it works fine, but how can I minimize redirects (gMetrix, Pingdom test)? – Tusko Trush May 06 '18 at 14:45
1

Please add access token parameter in the url

https://graph.facebook.com/id/picture?type=large&access_token=faskfjsld

This will work for sure.

1

There is an update here: https://developers.facebook.com/bugs/2054375031451090/

I just tried and it works, by simply appending your access token to the URL link.

So this:

https://graph.facebook.com/<userId>/?fields=picture&type=large

Should become like this:

https://graph.facebook.com/<userId>/?fields=picture&type=large&access_token=...

Hope it helps!

Dimitris
  • 419
  • 4
  • 19