I am using OWIN in mvc5 to authenticate users, but I want to show their profile pictures as well. I have searched on strackoverflow and found the following way to get it done.
This is for facebook & Google plus :
https://plus.google.com/s2/photos/profile/[USERID]?sz=100
http://graph.facebook.com/[USERID]/picture?type=square
Is this the best way to retrieve the images? Should we store images onto our server and load locally or we call these links every time someone logs in ? I need a proper approach, e.g. If we store them locally then they won't be updated if user changes their profile picture on facebook but if we load them every time from facebook then it takes some loading time to do a 302 redirect to actual image url.
If you're just trying to display the images on a website, I would just store the link your given from Facebook/Google when someone logs in to your site in a local database and use the URL as the image src on the website. Facebook and Google will be storing these images on fast CDNs, you might as well take advantage.
This will off load the image storage and the need to serve up images from your own site, reducing load and storage requirements.
Then every time a user logs into your site retrieve their profile pic urls again and store them to make sure they are up to date.
Related
I'm developing an app that authenticates users with Facebook. I'd like to display the user's profile picture in their account, which is readily accessible via a public Facebook URL.
Am I permitted to directly link to these images for use in our app, or do we need to download the image and re-host it on our own servers? I wasn't able to find any answer in the terms of service.
You should NOT use the CDN link, because that one may not be valid forever. It is perfectly fine to download the profile image - if you REALLY want to be safe, tell the user about it before he authorizes your App. You need to have a privacy policy anyway, stating what exactly you store about the user.
It is perfectly fine to use the Graph API link though. Depending on how many images you want to show, it may be better to still download them for performance reasons.
I use oauth with twitter/facebook/google+ to allow users of our website to signup and signin. We display the users' avatar with user generated content across the site.
With facebook the original image keeps the same url when the user change it (http://graph.facebook.com/[userid]/picture?type=normal)
But on twitter every image used as avatar has a different url (http://a0.twimg.com/profile_images/[slug]/[other_slug]_reasonably_small.jpeg)
What is the best practice to display these images, and what is allowed by the terms of use.
1- Download a copy of the image and create a media on our server, then users can change it as they see fit?
2- Always link to original image and update the link in user profile on sync?
I am trying to share a from my site on facebook
and it just wont display the image.
I tried the debug tool
and it says that every thing is ok...
the most wired thing is that when I put the same page on a different server it works fine!!!
and how can I clear the facebook cache ?
thanks alot
Check to make sure that there is not a setting on your server preventing Facebook from programmatically scraping the image data. I have recently run across this issue where the settings on a server were restrictively secure to the extent where Facebook was not able to grab the image data for sharing purposes and make a copy of the image into its CDN.
I've built my own blog with Facebook login. Currently, I'm using the following to show my FB user's profile picture at the top of the blog, to show they are signed in:
<img src="https://graph.facebook.com/[profileID]/picture">
Now I want to add profile pictures to each and every comment left on a blog article, and there are 20 comments per page. This means there are 21 requests going to FB for profile pics. Is this a good idea or should I be grabbing the profile picture from FB (programatically of course) and storing it locally?
I know how to grab the picture if I need to, I just want to know if what I'm doing is right or wrong? Very occasionally, I notice a little lag just loading one profile picture from FB, I'm concerned about loading 20 different ones.
Pros of using FB:
You don't waste your space
You don't waste your traffic
You don't waste your webserver connections/CPU/IO
You always have actual userpics on your page
FB has better CDN than you do
Each browser limits simultaneous HTTP requests per domain. So having different hosts (at least your one and FB one) could potentially improve page loading speed.
Cons of using FB:
If your app is an intranet one - FB would consume your users' internet traffic
OK this question is purely about which approach is better. I will not advise you to locally save profile pictures as user may change picture on their profile and you will end up with added responsibility of updating them.
More over once the picture is loaded from FB then for next 20 pictures browser will be using the cached image rather then making fresh requests to FB Server.
Hope it make sense
Thanks
Kaushik
I wrote an app for iPhone which lets you create a picture (kind of like photoshop). I wanted to let people share their pictures via Facebook for example, however their API only allows you to show images in a user's news feed via an image URL (you can't first upload a local image to the facebook servers and host it from there). It looks something like:
"Hey checkout what I made: ", "http://somesite.com/myimage.png"
I was thinking of creating an account at a site like photobucket.com, and whenever a user shares a picture in my app, I first upload it to the picture site, then use that url. I have a feeling that would somehow violate terms of use.
I could get an unlimited hosting account to store the pictures (like at godaddy) but don't think it would really scale very well as I'm sure an unlimited account really does have limits, just not advertised too well. Any suggestions on how I could get around this?
Thanks
You can most defently upload your images to Facebook, look at the API more closely, and check out Facebook Connect for iphone http://developers.facebook.com/connect.php?tab=iphone and here is the link for the API call to upload pictures http://wiki.developers.facebook.com/index.php/Photos.upload