Detecting profile picture change on Facebook - 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.

Related

Retrieve Facebook full name and picture from profile url

I'm trying to make a website with text input for facebook profile url and after procceeding, there should be user's name and profile image shown.
I saw something like that here: http://hackfbaccountlive.com/hack_account.php
(No, I'm not making another fb hack.)
I have been trying for a couple of hours now, and I always need to log in, and it's not working as I want.
Can you help me?
You should go into detail about what you're trying to do, as it sounds suspicious (please do not create a hack site). That being said, this all public information that can be fetched with the following calls:
https://graph.facebook.com/[user_id]
https://graph.facebook.com/[user_id]/picture
https://graph.facebook.com/[profile_username]
https://graph.facebook.com/[profile_username]/picture
You can then use either the UID or the profile username to create the profile URL, which is just https://www.facebook.com/[username_or_id]

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.

Adding Facebook Photo objects to Open Graph Action

I've created a timeline app that adds events to user's timelines in the past. I've noticed its simple to add tags, places, and external images to OG objects and actions.
However, I can't seem to find a good way to connect to a facebook photo (i.e. a photo from the user's albums). Adding a link to the photo's picture in the images field doesn't work the expected way without an access token (which will presumably expire)
For example: /namespace:action?image=http://graph.facebook.com/10100111692798728/picture will show a '?' photo (in aggregations and elsewhere) unless you pass a valid access token in too (that can't work permanently). This is presumably because whatever identity is going out to request the photo is not allowed to access it this way.
It doesn't seem like you can connect your own actions to photo objects either. Is there a solution to this that I've missed. I'd really like user's to be able to add a photo from their facebook albums to an action from my app (i.e. them doing the 'action'). It would be nice if you didn't have to point directly at an image on FB's CDN somewhere, it would be even nicer if there was a way to point directly at the FB open graph object.
Thanks,
Grant
It is possible to connect the action with Facebook photo like this:
POST /me/do:action?object=[objectId]&access_token=[valid access token]
If the [objectId] is an object id of existing photo - it will show the picture and correct link to the full size facebook photo on timeline.

How to find out which user clicked an image on my facebook website/application?

Say I have a facebook page/app that contains images of products that I sell. Is there a way that I can find out who the user details(facebook account) is when an image is clicked?
Assumption I am making:
You are using a custom page tab
The page tab is an iframe
You have GDPed the user when they clicked on the body of the tab
You now know the user in the app on the tab
All actions by the user contain the user ID (so you can customize the experience)
Then you're already done!
C # facebook
you can take it by IP from access log, or you have to aim all images to php file (to log user data) before showing image
From my knowledge, the user has to connect with your app first, before you can get his user id. After you have this piece of information, it's rather simple to log all his requests.
Assuming that clicking on a product image doesn't necessarily send the user to a new URL, but maybe shows a zoomed image or shows more information, you could use Javascript to send an Ajax request to your server containing information about the product and FB user id. The URL can look something like this:
http://example.com/log.php?uid=xxx&product_id=ppp
Then server-side you'll store the information in the database.

Testing if user has posted a facebook profile picture and if so, retrieving it?

What is the correct way of verifying that a user has put in a facebook profile picture (ie the non-default one), and if so, to retrieve it?
This: How to determine if a Facebook user has uploaded a profile picture or its default? talks about a method, but the author himself says that its a bad method:
public static function hasProfilePicture($fbuid)
{
/* Really stupid method to test if Facebook user has real profile picture
* based on FB returning a gif when you request a large photo.
* Use with care - for every profile there's an outgoing request! */
$r = get_headers("http://graph.facebook.com/$fbuid/picture?type=square");
return !array_search("Content-Type: image/gif",$r);
}
If a user HAS a profile photo, it can be accessed via http://graph.facebook.com/<facebook username>/picture. For example, http://graph.facebook.com/gauravgupta.in/picture redirects to a specific URL and shows my Facebook profile picture.
However, if a user does NOT have a profile picture, the above URL gets redirected to the URL of the standard placeholder image, which is currently http://profile.ak.fbcdn.net/static-ak/rsrc.php/v1/yo/r/UlIqmHJn-SK.gif
It's definitely not a reliable way, but will work till Facebook decides to change it.