I'm trying to include users profile picture from facebook, which works fine, but the thing is when you want to include it on a SSL-secured page. I can't find a way to get the picture to load from a secure location. Using the following link to the users profile pic:
https://graph.facebook.com/<FB_ID HERE>/picture?type=square
Even though I use https it doesn't get loaded securely (browser says the page is just partially encrypted). And this isn't strange since the link just redirects to the images, for example for my profile picture:
https://graph.facebook.com/Bazze/picture?type=square
This will get the picture from:
http://profile.ak.fbcdn.net/hprofile-ak-snc4/161513_633115680_6792455_q.jpg
Note that that is not a secure location.
Anyone know how to load the profile picture securely through the https protocol?
Thanks!
Add return_ssl_resources=1
to your Graph call:
https://graph.facebook.com/<FB_ID>/picture?type=square&return_ssl_resources=1
This is the proper way to get a SSL-served image; the redirect will be to a https server with a proper SSL certificate.
Update: It appears Facebook will now automatically give you a redirect to https-hosted images when you use https://graph.facebook.com, so the return_ssl_resources
parameter is no longer necessary.
Using http://graph.facebook.com still gets you a http-hosted image.
Well, https://graph.facebook.com/Bazze/picture?type=square is a 302 redirect to http://.... But note that https://... still works (example).
So it looks like one solution is to parse the 302 yourself, insert the 's' in the appropriate place, then fetch the image. But on the downside, the linked page above has certificate errors, and there isn't a good way to fix that.
(I'm not saying this is a good answer...)
The 302 redirect will have your picture URL as stated in the Open Graph API documentation.
The you need to change from: / http profile.ak.fbcdn.net / to: / https fbcdn-profile-a.akamaihd.net /
And from: / http static.ak.fbcdn.net / to: / https s-static.ak.fbcdn.net /
I really think that FB should do that in their API's !!!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With