Retrieving facebook profile ID from image url - facebook

Given the url of a facebook-hosted image, which looks something like,
https://scontent-a-lax.xx.fbcdn.net/hphotos-xaf1/t1.0-9/XXXXXXX_XXXXXXXXXXX_XXXXXXX_n.jpg
how can I get the Graph API Photo ID of the image?
I tried using the second number in the image filename as the photoid, but this no longer seems to work. Has facebook changed the URL format, and if so, how?

Related

Link between current profile picture and the original photo in the profile album

I want to have a link between the currently used profile picture and the original source in the profile album.
I'm getting the profile picture with:
/me/picture?redirect=false
Which will return url, width & height but unfortunately no id. (https://developers.facebook.com/docs/graph-api/reference/profile-picture-source/)
I'm getting all the albums with:
/me/albums?fields=id,type
Then I'm iterating through all the albums to find the one with the type=='profile' and then retrieve all the photos of this album:
/{albumId}/photos?fields=width,height,id,images
How can I identify the photo used as the profile picture?
Since we have no id returned from the /me/picture endpoint I don't see a way to make the link between the two objects.
Also, I'm not sure that we can rely on CDN urls to parse them and try to find the profile picture id.

Facebook does not allow post photo url, which refers to the Facebook's server

I try to use this picture url when I share post to the Facebook wall
https://fbcdn-photos-e-a.akamaihd.net/hphotos-ak-prn2/t1/1509934_1399389213653861_1680466495_a.jpg.
But I get an error, which says: "An unknown error has occurred.". It's very strange, because when I try to use this picture url:
http://zastavki-oboi.ru/thumbs/oranjevyi_cvetochek-4636.jpg
I do not get any errors.
I really do not understand, why first one does not work, but second one works correctly!
Any ideas?
You probably want to post to the /feed edge with an object_attachment specified. The object_attachment being the Facebook object ID of the image you want to share. The app user will also need to be the owner of that photo.
object_attachment
Facebook ID for an existing picture in the person's photo albums to
use as the thumbnail image. They must be the owner of the photo, and
the photo cannot be part of a message attachment.
See under Publishing: https://developers.facebook.com/docs/graph-api/reference/user/feed/#
And a note, if you only have the url of the image, the object ID should be the middle set of numbers in the filename. 1509934_1399389213653861_1680466495_a.jpg.

URL for Facebook album id

Is it possible to get URL for Facebook album id (fbid) without any request?
Like I can get URL for photo - https://www.facebook.com/photo.php?fbid=FBID
I need a valid URL for use with Graph API in link field.
http://www.facebook.com/FBID - is not valid, because shown as plain text in link field.
If albumid is 1256641940078, the URL is
http://www.facebook.com/1256641940078
Nodes in the Graph API have a unique ID and you can generally link to anything like this if you just know that ID. For example you can even link to a person like http://www.facebook.com/297200003
Do this:
http://graph.facebook.com/FBID?fields=link
Example: http://graph.facebook.com/537137506325516?fields=link
You better use user access token for private photo.

How to post an image link to Facebook feed using graph API

I'm trying to post a picture to a feed using the graph API but this does not work if my image url does not have an image filename extension such as .png
(I have a URL to a png without the .png file extension as the image is created dynamically on the server)
This does seem to work when I manually post the link on my Facebook wall. Facebook wraps the URL like this:
http://external.ak.fbcdn.net/safe_image.php?d=AQAsdfyQsdfXvV5h59OP&w=90&h=90&url="my image url"
Does anyone know how I can post the URL of an image to the picture field of a feed post?
Facebook downloads and caches any image posted on the wall. It is then distributed on their CDN (content delivery network).
The reason is simple: load times. If someone posts an image from a slow server on FB, this could make experience of Facebook slow. So they copy all that.
So
maybe Facebook still has an old copy. Try with a fresh URL.
can facebook access the URL, or only your user?

how to post photo with text to facebook wall

Current, I can upload a photo to an user's album. but I can't use the url of this photo(assemble the url by the photo id), it says:"FBCDN image is not allowed in stream", I also figured out that facebook forbid user to do this.
I know that I can upload the photo to somewhere else on the internet, but actually I don't have that 'somewhere', so how does everybody do ?
You dont need to assemble the url of the picture you just uploaded. Instead, use the photo_id that you got back and make another call to the Graph api :
https://graph.facebook.com/{PHOTO_ID}
The response from that call will contain all the information you need (including a link to the photo on facebook).