Adding Facebook Photo objects to Open Graph Action - facebook

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.

Related

Howto select image from facebook

On my website there is possible post image from computer. But I would like also provide user to post image from facebook user album. I can imagine some dialog like "Facebook login" which will open faceook images and provide user to send image from facebook to my application. Does something like that possible? Many thanks
Yes, it is possible.
I assume you have a little experience with facebook api.
trigger login FB login window and request user_photos permission
make a query to facebook to get (all/random/a few) user albums like so me/albums?fields=id,count
If a key count is set, there are photos
(I would collect all IDs of albums containing photos and make a query to facebook with ech one ID)
Then again, query to facebook like so /%album-id%?fields=photos.fields(images)
Now you have an array of URLs of images which, for example you show to a user and after he selects, you download it and upload to your server
Since you did not request a solid code, I will provide you with at least with a little snippet, or show an illustration how to do that. http://paste2.org/hvGkngIL. (a metod index) (Might not work properly, since I cut it from a PHP framework I work with)

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.

Link a posted photo with an app page

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.

Are Facebook Graph items persistent?

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.

Facebook Open Graph, can I upload a User Generated Photo (as opposed to sending a URL)?

I've read the documentation here.
I have an action, "cook", which is applied to an object "recipe". I want to allow the user to post a photo of their cooking when they perform the action.
I would like to have the photo hosted on Facebook. Is there any way to post the actual image data as part of the request, rather than posting a URL to the user generated photo?
The docs say
The photo used will NOT be taken from the object's meta data og:image tag. Instead, it is passed with the POST
and
The photo will be uploaded and placed in a Facebook photo album titled after the "App Display Name" for that app
but they also mention that the image[0][url] property is required.
The context is an iOS app: the user takes a photo on the device and wishes to post it to Facebook. To get a URL to the image, I'd obviously have to do an upload to some web hosting somewhere as a separate step, which would be harder to code and would require some hosting.
but they also mention that the image[0][url] property is required.
You’ll have to upload the photo first to some place where it’s available over the web via HTTP, and then give that URL while posting your action.