Getting a High Resolution picture from Facebook API - facebook

Facebook FQL API for Photos states the maximum resolution for a photo returned from the API is 960x960:
The Photo object has an equivalent src connection. Using photo_src
FQL, you can retrieve images with the following dimensions: 960, 720,
480, 320, 180, 130, 75 pixels.
However, some images are uploaded at a higher resolution. Sometimes even much higher.
When browsing Facebook regularly, you can see these pictures and view their full size. However, I can't seem to find any way to get the original resolution in the API.
Is this possible and I have missed something? And if it's not - why?

Getting the max size of a picture
/USER_ID?fields=images
images gives back "an array of objects containing width, height, source each representing the various photo sizes". The result looks like this:
{
"data": [
{
"images": [
{
"height": 1536,
"width": 2048,
"source": "https://fbcdn-sphotos-c-a.akamaihd.net/hphotos-ak-prn1/s2048x2048/65169_XXXXXX_n.jpg"
},
{
"height": 720,
"width": 960,
"source": "https://fbcdn-sphotos-c-a.akamaihd.net/hphotos-ak-prn1/65169_44590146XXXXXXXXn.jpg"
},
{
"height": 540,
"width": 720,
"source": "https://fbcdn-sphotos-c-a.akamaihd.net/hphotos-ak-prn1/s720x720/65169_44XXXXXXX0984540_n.jpg"
},
{
...
},
{
"height": 97,
"width": 130,
"source": "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-prn1/s75x225/65169_44XXXXX_s.jpg"
}
],
}
]
}
Getting the max size of a profile picture
Try with more than 960, i.e 961. You'll get the maximum size of the picture, if available!
/USER_ID?fields=picture.height(961)
Result:
{
"id": "PROFILE_ID",
"picture": {
"data": {
"url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/615962_4486XXXXXXXXX3_601495975_o.jpg",
"width": 1536,
"height": 2048,
"is_silhouette": false
}
}
}

Related

getting multiple photos from Facebook post

I'm now playing with Facebook's Graph API and I'm trying to copy Facebook's posts from a page that I'm administrating to another place.
So far I managed to succesfully get message and full_picture, the problem begins with posts that have several pictures in as if I never get more than one picture from a post.
Graph API reference for posts tells only about returning one link for one picture or full_picture and I didn't find any mentions about getting the biggest number of pictures possible.
Is there any way to get all pictures from posts?
You can get them via the attachments, at least for posts I have made
$ okurl https://graph.facebook.com/v3.1/10153937378849343_10156680000194343/attachments
{
"data": [
{
"subattachments": {
"data": [
{
"media": {
"image": {
"height": 540,
"src": "https://scontent.xx.fbcdn.net/v/t1.0-0/p180x540/xxx_n.jpg",
"width": 720
}
},
"target": {
"id": "10156680000094343",
"url": "https://www.facebook.com/photo.php?fbid=xxx"
},
"type": "photo",
"url": "https://www.facebook.com/photo.php?fbid=xxx"
},
{
"media": {
"image": {
"height": 540,
"src": "https://scontent.xx.fbcdn.net/v/t1.0-0/p180x540/38918411_10156680000119343_5451882299853373440_n.jpg?_nc_cat=0&oh=ac71357254bb90e14e4a658531ff370b&oe=5C08C9C2",
"width": 720
}
},
"target": {
"id": "10156680000109343",
"url": "https://www.facebook.com/photo.php?fbid=xxx"
},
"type": "photo",
"url": "https://www.facebook.com/photo.php?fbid=xxx"
}
]
},
"target": {
"id": "10156680000194343",
"url": "https://www.facebook.com/542634342/posts/10156680000194343/"
},
"title": "Photos from My post",
"type": "album",
"url": "https://www.facebook.com/542634342/posts/10156680000194343/"
}
]
}

Kairos enroll API returns confidence in the response. What does it mean?

I am exploring Kairos Facial Recognition APIs. The API /enroll is used for uploading an image to Kairos for a subject_id. I noticed that the response of enroll API contains a confidence score. The image is treated as a new image. What does this confidence mean? When you verify an image, in that case the confidence score is important. But while uploading an image, why does the API return a confidence?
I assume, the API compares the image to the images uploaded before for that subject_id and returns the confidence. Is this the case or is it something else?
API Documentation: API_docs.
Here is a sample response for reference:
{
"face_id": "f2f0f8de43e545f8aff",
"images": [
{
"attributes": {
"age": 40,
"asian": 0.13225,
"black": 0.00103,
"gender": {
"femaleConfidence": 0.00028,
"maleConfidence": 0.99972,
"type": "M"
},
"glasses": "None",
"hispanic": 0.09578,
"lips": "Together",
"other": 0.27899,
"white": 0.49195
},
"transaction": {
"confidence": 0.99932,
"eyeDistance": 30,
"face_id": "f2f0f8de43e545f8aff",
"gallery_name": "ps-recognize",
"height": 70,
"image_id": 1,
"pitch": -14,
"quality": 0.10107,
"roll": -4,
"status": "success",
"subject_id": "vinod-khanna.&**#~`%$#_=+/",
"timestamp": "1526029231708",
"topLeftX": 124,
"topLeftY": 42,
"width": 70,
"yaw": 1
}
}
]
}
Yes, this isn't clear from the documentation.
For /recognize and /verify the confidence % represents how similar the face sent in with the request is to the the face being compared against.
For /detect and /enroll the confidence represents how confident the engine is that it found a face. Usually you will see 98-99 percent range for those values.
Disclosure: Kairos.com CTO

Bigger picture for facebook news feed

I tried the Facebook Graph API Explorer and looked into the news feed of a person with /[userid]/feed.
In this case, the person added a new cover photo which is at least 720px wide.
But in the news feed, all I found was a picture attribute containing a very small 130px wide thumbnail only.
Is there a way to access the full - or at least a bigger - picture within the API?
Thank you.
If you check the data coming back from the /[userid]/feed API call, you'll notice "object_id": "xxx" in the response.
If you make a second API call to this, e.g. /xxx/, you will get an array of images back with different sizes you can use. E.g.:
{
"id": "000",
"created_time": "...",
"from": {
...
},
"height": 223,
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yz/r/StEh3RhPvjk.gif",
"images": [
{
"height": 480,
"source": "https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-xfp1/t31.0-8/1912152_448929725237759_238021965_o.jpg",
"width": 1547
},
{
"height": 320,
"source": "https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-xfp1/t31.0-8/p320x320/1912152_448929725237759_238021965_o.jpg",
"width": 1031
},
{
"height": 130,
"source": "https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-xpa1/t1.0-9/p130x130/1013838_448929725237759_238021965_n.jpg",
"width": 420
},
{
"height": 225,
"source": "https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-xfp1/t31.0-8/p75x225/1912152_448929725237759_238021965_o.jpg",
"width": 725
}
],
"link": "https://www.facebook.com/147587828705285/photos/a.448909598573105.1073741827.147587828705285/448929725237759/?type=1",
"picture": "https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-xpa1/t1.0-9/s130x130/1013838_448929725237759_238021965_n.jpg",
"source": "https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-xfp1/t31.0-8/q71/s720x720/1912152_448929725237759_238021965_o.jpg",
"updated_time": "2014-03-12T19:58:08+0000",
"width": 720
}

What are the recommended ways to handle references to embedded documents in MongoDB?

I'm new to MongoDB. Here's my problem: a user can have multiple avatars, but one and only one is active. Here's what a user document looks like for the moment:
{
"_id": ObjectId("515c99f7e4d8094a87e13757"),
"avatars": [{
"url": "http://example.com/img/photo1.jpg",
"width": 50,
"height": 50,
}, {
"active": true,
"url": "http://example.com/img/photo2.jpg",
"width": 50,
"height": 50,
}]
}
This solution is simple enough, but there are a few things I don't like:
changing the active avatar means updating two embedded documents
I'm not sure it will behave nicely in case of concurrent access (read_avatar+change_active_avatar or change_active+change_active) (will it?)
looking for the active avatar requires a sequential search
Another solution would be this:
{
"_id": ObjectId("515c99f7e4d8094a87e13757"),
"active_avatar_id": 2,
"avatars": [{
"_id": 1,
"url": "http://example.com/img/photo1.jpg",
"width": 50,
"height": 50,
}, {
"_id": 2,
"url": "http://example.com/img/photo2.jpg",
"width": 50,
"height": 50,
}]
}
This fixes problems 1&2, but not problem 3. And it adds an extra _id field in every embedded document. Plus when I insert a new avatar I now need to know what's the next _id to use (unless I use an objectId, but then it's a 12 bytes id for just a few hundred avatars (max).
So yet another solution could be this:
{
"_id": ObjectId("515c99f7e4d8094a87e13757"),
"active_avatar": {
"url": "http://example.com/img/photo2.jpg",
"width": 50,
"height": 50,
},
"extra_avatars": [{
"url": "http://example.com/img/photo1.jpg",
"width": 50,
"height": 50,
}]
}
Not much better than the first solution (it just fixes problem #3, that's it, and it's uglier).
All these solutions work, but I'm looking for "the right way" to do it. Any ideas? And what if I allow users to have multiple active avatars (whatever that would mean)?
Thanks.
Have you considered the document inside a document model?
{
"_id" : ObjectId("515c99f7e4d8094a87e13758"),
"active_avatar_id" : 2,
"avatars" : {
"1" : {
"url" : "http://example.com/img/photo1.jpg",
"width" : 50,
"height" : 50
},
"2" : {
"url" : "http://example.com/img/photo2.jpg",
"width" : 50,
"height" : 50
}
}
}

Items in the images array of the facebook photo object does not contain a source anymore

We were using photo's from facebook in our application until we noticed today that there was no longer a source field available for the different sizes of the image.
I saw in the facebook documentation that there should be a field "source" for every item in the images array.
images | The 4 different stored representations of the photo |
Requires access_token | array of objects, containing height, width,
and source fields
Here's the json data i get from facebook:
{
"id": "10150916781197589",
"from": {
"name": "Thomas Dekiere",
"id": "641457588"
},
"name": "antwerpen",
"picture": "http://photos-b.ak.fbcdn.net/hphotos-ak-snc7/383569_10150916781197589_641457588_12988491_2098011643_s.jpg",
"source": "http://a2.sphotos.ak.fbcdn.net/hphotos-ak-snc7/s720x720/383569_10150916781197589_641457588_12988491_2098011643_n.jpg",
"height": 720,
"width": 478,
"images": [
{
"width": 1360,
"height": 2048
},
{
"width": 637,
"height": 960
},
{
"width": 478,
"height": 720
},
{
"width": 318,
"height": 480
},
{
"width": 212,
"height": 320
},
{
"width": 180,
"height": 271
},
{
"width": 86,
"height": 130
},
{
"width": 86,
"height": 130
}
],
"link": "http://www.facebook.com/photo.php?fbid=10150916781197589&set=a.10150916780582589.528576.641457588&type=1",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v1/yz/r/StEh3RhPvjk.gif",
"created_time": "2012-04-04T13:42:09+0000",
"position": 1,
"updated_time": "2012-04-04T13:42:19+0000"
}
as you can see, there's no source field in the images array items.
Is this normal behavior now and is the documentation out dated or is this a facebook bug?
There was a bug in the facebook service:
http://developers.facebook.com/bugs/328741343854109
It has been solved :)