how to store facebook profile pic in database? - facebook

as we know that to get a profile picture we use this url (graph.facebook.com/1700278611/picture)
but when i want to store it in database it is not working can anybody tell me how to save that image in database as we know this url (graph.facebook.com/1700278611/picture)
redirect to this url (http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs222.ash2/48814_1700278611_949486_q.jpg) so pls help thanks in advance

You can just store img_url as graph.facebook.com/FB_USER_ID/picture in database. In your webpages, you can simply use that URL like <img src="http://graph.facebook.com/FB_USER_ID/picture" /> to display the image.
You do not really need to know the "real" image URL. In-fact, that may eventually get defunct if user delets or changes his profile image. So, real image URL may not be advantageous. On the other hand, the symbolic URL provided by graph API will always point to the latest user image.

Related

Facebook take the wrong image on sharing. (Dynamic image generate for facebook robot)

I know there is a tons of questions about Facebook share... but trust me, I'm trying something different than the normal way of sharing.
Well, I have an Facebook image generate website, but I don't wanna to generate images every time an user enter. So its create an canvas, and then a "og:image" url with an ID..
Then when someone hit the share button, it open the Facebook UI, and:
-Facebook goes into the url with an ID.
-the php script check if the image is already created.
-if not, create the image and save it on amazon S3.
-an finally redirect to the S3 url.
The problem is, if I hit the share btn and post right after it has open... Facebook take an random image of the page.. its like he can't wait the processing and just give up o.o
Someone please know how to prevent it to happen?

Detecting profile picture change on Facebook

Is there any way to find out if a user has changed his/her profile picture since a time given? I mean, is there a proper way to achieve that using Facebook API?
One solution would be to store image id when user registers and later with CRON do a query to see if current profile picture id is the same id as one stored, if different then used changed the profile picture.
Second solution is to have access to user feed and from there to check if profile picture was changed, also CRON will be used.
Note: if you plan to use user picture in your app there is no need to check if picture was changed, facebook will always send you the current one.
You should check ETags. It is some kind of has witch you get in response header. You should store that value and send it next time you make request for image. If image was not changed you will get 304 - Not Modified response from Facebook API.
If you do not want to download images from Facebook you should use ?redirect=false paramter in Facebook image request (eg. https://graph.facebook.com/<username>/picture?redirect=false). This will return json data of profile picture instead of returning the whole image.

Share generated personal image to FB with Opengraph

I'm stuck with this problem for several weeks now and will try to give a short and detailed explanation below:
Situation
Users visiting the websites and has the option to generate an image with the GD-library. So every users generated a personal image. Simple... until now. After generating the image, the user gets the option to share this image to Facebook. This is done via the OpenGraph protocol.
What's working (Yeah!)
Generating the image is working perfectly fine. Sharing something to Facebook is working also.
Problem
Although the following code is used on sharing the image (fbrefresh=CAN_BE_ANYTHING). FB stills pulls an old image. Sometimes this is a really old image, sometimes it's a more current generated image. But never the just generated image.
And now?
As said I've already tried the fbrefresh=CAN_BE_ANYTHING. Also in de debug tool the right image isn't showing up, but this is probably because the generated image has an unique ID generated from the users cookie. So this id is only usable when the users clicks on generate and after that shares the generated image.
Is there any example on the internet that uses the same sort of strategy and is working? I've searched half the internet and didn't found it yet it's becoming more and more frustrating.
After generating the image, the user gets the option to share this image to Facebook. This is done via the OpenGraph protocol.
What exactly do you mean by the latter? Are you just uploading that image to the user’s wall/one of their albums, or are you publishing an Open Graph object with a user-generated photo attached? (Btw., user-generated photo is meant literally for OG actions – you should only do it with photos that the user has taken using f.e. their mobile phone camera while they where undertaking the action. I doubt if a GDlib-generated image fits into that description.)
Although the following code is used on sharing the image (fbrefresh=CAN_BE_ANYTHING). FB stills pulls an old image.
And by “pull” you mean what exactly, again? Do you upload the photo as an HTTP POST upload, do you upload it by URL, did you specify it as og:image for an OG object, or do you pass it as user-generated photo while publishing an action?
Now, usually the easiest way for resources referenced by a URL to get properly refreshed by the requesting client, is to attach a different value to the query string/as a GET parameter – f.e. the current unix timestamp: …/image.php?1984372634 or …/image.php?foo=bar&forcerefresh=1984372634
Since this value changes every second, it makes each of those URLs a different URL, and the requesting client absolutely has no choice but to request that resource, because he can not have it in its cache already.

Facebook Image URL is invalid (Graph API)

I am developing a Facebook game. In that the 10 opponent picture is displayed. I had saved these profile images in the database once the user had registered.
I am using PHP to echo the image, but the problem is some pictures are being displayed and others are giving me a ‘404’ / ‘400’ or ‘Invalid URL ‘ not found error.
Example: ( These images earlier used to be displayed but not anymore)
http://sphotos-a.ak.fbcdn.net/hphotos-ak-ash3/522851_116822898455075_142765921_q.jpg
https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-snc6/199347_134645999940053_5814468_q.jpg.
How can I fix this problem? Or find some alternative so that the
broken link of these images is not displayed.
I am having the user ID
of these users, Can I somehow generate new picture if these picture links
are detected as broken?
Is it advisable to hotlink the Picture URLs ? I don't want this
problem to occur again?
I would appreciate if some one could help me.
You can use this url to fetch profile images of any user using his/her FB user id's
https://graph.facebook.com/<fb USER ID>/picture?type=large

How do i get someones profile picture to display back to them?

How do i get someones profile picture to diplay back to me. I have already gotten permissions to use the user's pictures etc i just don't know how to use their profile picture and display it back to them.
Any help would be awesome
Calling on the Graph API
http://graph.facebook.com/[id]/picture
The following will give you different sizes
http://graph.facebook.com/[id]/picture?type=square
http://graph.facebook.com/[id]/picture?type=normal
http://graph.facebook.com/[id]/picture?type=large
So you can just put these URLs straight in an <img> tag
EG: <img src="http://graph.facebook.com/4/picture?type=square" />
See:
http://developers.facebook.com/docs/reference/api/#pictures
These are in the public domain, so there is no need for any authentication.