I am wondering if it is safe to cache Facebook graph items and not have to check if they have been changed.
For example, if I download and cache of photo with the ID 1234309932123, is it safe to assume that the image for that ID will always be the same?
I assume that a given Facebook object cannot change, it can only be deleted. Is that correct?
It is wrong to assume that photo object will not change. Photo is not only image but associated data as well, at least some of properties for photo can be changed: title, description, people/pages tags.
One more thing that can be changed aside of photo details is access permissions. Platform policies states that you should only show data retrieved from Facebook to people who have permission to view it, so caching photo may became an issue.
Related
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.
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.
I'm designing a photo-oriented Facebook app that would let users tell stories in the app-specific way and advertise such stories by posting a single, preferably large, "cover" photo. Photo posting is done by the app and people that would like to see the story need an easy and obvious way of being redirected to the corresponding app-generated page. So hence is the question.
Is it possible for a Facebook app to post a maximally large (column-wide) photo on the user's behalf, so that when others (non-users included) click on the photo, it takes them to a specific page that is related to the app instead of zooming into the photo by default? If not, what would be the best workaround?
To get the maximum large photo on news feed, you should look into user generated photos, which requires two additional parameters you add to your open graph action to indicate that the user-generated photo should have maximum photo display on news feed and ticker.
Example OG POST:
https://graph.facebook.com/me/nyccookbook:cook?
recipe=http://www.yourdomain.com/pizza.html&
image[0][url]=http://www.yourdomain.com/images/my_camera_pizza_pic.jpg&
image[0][user_generated]=true&
access_token=YOUR_ACCESS_TOKEN
If the photo is not user-generated, then explicit sharing is an alternative to get maximum display size on news feed and ticker provided that you follow all the requirements and guidelines for explicit sharing.
when others (non-users included) click on the photo, it takes them to a specific page that is related to the app instead of zooming into the photo by default
This is not possible because FB users expect the behavior to zoom the photo in when clicking on it. If clicking on a photo launches an URL, it is a bad user experience because that is not what anyone expects when clicking on a photo on FB.
The best workaround I can think of is to edit the description of the image with a link to your specific page on your app, such that when a FB user sees the picture, they can click the link in the description to go where you want.
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.
I am successfully uploading photos with my iPhone App and the corresponding Graph API calls, and it ends up properly in an (automatically created) album "appName Photos" on a new account w/o existing albums. Uploading to my own account, however, puts the photo to "Camera + Photos", the first of multiple albums existing for my account, instead of creating a new one for my app.
Anything I need to consider specifically to enforce creation of an app-related album? Do I need to go through an explicit album creation process first? I thought all the required information would be provided by the logon procedure, containing the appID (and seemingly does when using the "empty" account)?
EDIT:
I just had the albums programmatically listed, and actually an according album WAS created and is returned in the list of albums now, however it does not show up and contains no photos. So maybe it is rather a bug that the actual upload is taking place to the next album in the row (maybe some race condition on the FB side)?
Thx for insight, habitoti
By default, it should work that way (as described in the docs) but it appears to be a recent change to no longer enforce creation of an app-related album but to use a default album for all posted photos that aren't explicitly added to a specific album.
You'll want to use the procedure described here (look at the second chunk of code) to ensure that it creates an application-named album.