Accessing to the Facebook profile picture - json

I am using Firebase in order to do a Facebook auth, I would like to know how to display and access to the profile picture from the returned json which looks like this
{
"uid": "facebook:1419891304993631",
"provider": "facebook",
"facebook": {
"id": "1419891304993631",
"accessToken": "CAAJdUVn89vwBAKYZASyfcpTEeSNZApxJEy7xDoCe8M02xZBCJeW6bneWbPJiXYXo0Oe3BVt4hL4xmVkQG5DnQPUs4AeXf67vx2p5kXPvk0vgsB7EPWUhDQzDZAXa1JLdCZBaVhNDtv39dqyH24qwqVzTxKqH8DRPeSPqga5DjZBsAaqmhcaMyPNXZB26NPZA8RZCS8J0zZAmyO67Lq7W5y3der",
"displayName": "Aaron Hillel Swartz",
"email": "retana.marcelo#gmail.com",
"cachedUserProfile": {
"id": "1419891304993631",
"name": "Aaron Hillel Swartz",
"last_name": "Swartz",
"first_name": "Aaron",
"middle_name": "Hillel",
"gender": "male",
"link": "https://www.facebook.com/app_scoped_user_id/1419891304993631/",
"email": "retana.marcelo#gmail.com",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfp1/v/t1.0-1/s100x100/111…77b0ef39e0&oe=55A9B547&__gda__=1436644689_2ba73b2df6e584b46e5a2f8000d571d8"
}
},
"age_range": {
"min": 21
},
"locale": "es_LA",
"timezone": -6
}
},
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2IjowLCJkIjp7InVpZCI6ImZhY2Vib29rOjE0MTk4OTEzMDQ5OTM2MzEiLCJwcm92aWRlciI6ImZhY2Vib29rIn0sImlhdCI6MTQyOTA4NTA4OH0.ec-5bS1-sTSUfeBwDZRwncZxuABrHwnlIQY5eLYxQBQ",
"auth": {
"uid": "facebook:1419891304993631",
"provider": "facebook"
},
"expires": 1429171488
}
example, with this
<div ng-bind="user.uid"></div>
I can display de user uid which is facebook:1419891304993631 in this case, so, with angular, how can I access to the profile picture property ?
Is there a way to use like a kind of ng-src for this?

Related

Update a Contentful post using PUT request via Postman

I'm trying to update a Contentful entry using Postman.
What I did:
In Contentful space, I created a test post to play with.
Went to Settings - API Keys - Content management tokens and generated a Personal access token
Created a GET request in Postman, passing space ID, master environment, and ID of the test post:
https://cdn.contentful.com/spaces/{spaceID}i/environments/master/entries?sys.id={postID}
I also sent authorisation header with content delivery token.
The GET request goes successfully and I'm able to copy the JSON object-response.
{
"sys": {
"type": "Array"
},
"total": 1,
"skip": 0,
"limit": 100,
"items": [
{
"metadata": {
"tags": []
},
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "d9r4mg123x4v"
}
},
"id": "2Fwow39hxxx1bvMkjpsyV9",
"type": "Entry",
"createdAt": "2021-11-10T14:00:11.935Z",
"updatedAt": "2021-11-10T14:06:51.393Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"revision": 3,
"contentType": {
"sys": {
"type": "Link",
"linkType": "ContentType",
"id": "hotelInfo"
}
},
"locale": "en-US"
},
"fields": {
"name": "Test entry",
"slug": "test-entry",
"address": "Lviv",
"cityName": "Lviv",
"phone": "+380931231212",
"coordinates": {
"lon": -115.302,
"lat": 36.18709
},
"dog": "100",
"cat": "100",
"delivery": "100",
"photo": [
{
"sys": {
"type": "Link",
"linkType": "Asset",
"id": "2hSnYhQDJzU99NvlsYdk3k"
}
}
],
"additionalInfo": {
"data": {},
"content": [
{
"data": {},
"content": [
{
"data": {},
"marks": [],
"value": "Test",
"nodeType": "text"
}
],
"nodeType": "paragraph"
}
],
"nodeType": "document"
},
"featuredHotel": true,
"phoneClicks": 1
}
}
],
"includes": {
"Asset": [
{
"metadata": {
"tags": []
},
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "d9r4mg123x4v"
}
},
"id": "2hSnYhQDJzU99NvlsYdk3k",
"type": "Asset",
"createdAt": "2021-11-10T13:59:59.954Z",
"updatedAt": "2021-11-10T13:59:59.954Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"revision": 1,
"locale": "en-US"
},
"fields": {
"title": "JS",
"description": "Lorem Ipsum",
"file": {
"url": "//images.ctfassets.net/d9r4mg123x4v/2hSnYhQDJzU99NvlsYdk3k/6fbabc7be7f4b28dc8b7deadd9892205/JS.png",
"details": {
"size": 23078,
"image": {
"width": 1024,
"height": 1024
}
},
"fileName": "JS.png",
"contentType": "image/png"
}
}
}
]
}
}
Now I want to create PUT request to send the updated JSON to the Contentful.
I paste the JSON I got as a response from GET request.
I change one of the values:
"name": "Test entry"
to
"name": "Test entry 123"
I send PUT request to https://api.contentful.com/spaces/{spaceID}/environments/master/entries/{postID}
The Authorisation header contains the Personal access token I generated before.
The X-Contentful-Version header contains the version of the post, can be found in post details
When I send this request, I get JSON response with an empty "fields": {}
{
"metadata": {
"tags": []
},
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "d9r4mg123x4v"
}
},
"id": "2Fwow39hxxx1bvMkjpsyV9",
"type": "Entry",
"createdAt": "2021-11-10T13:57:10.882Z",
"updatedAt": "2021-11-11T10:58:39.480Z",
"environment": {
"sys": {
"id": "master",
"type": "Link",
"linkType": "Environment"
}
},
"publishedVersion": 13,
"publishedAt": "2021-11-10T14:06:51.393Z",
"firstPublishedAt": "2021-11-10T14:00:11.935Z",
"createdBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "4123123123zOn3MkhuVB"
}
},
"updatedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "4123123123zOn3MkhuVB"
}
},
"publishedCounter": 3,
"version": 23,
"publishedBy": {
"sys": {
"type": "Link",
"linkType": "User",
"id": "4123123123zOn3MkhuVB"
}
},
"contentType": {
"sys": {
"type": "Link",
"linkType": "ContentType",
"id": "hotelInfo"
}
}
},
"fields": {}
}
And in Contentful Admin area, all the fields of the post become empty.
Contentful documentation says:
Contentful doesn't merge changes made to content, so when updating
content, you need to send the entire body of an entry. If you update
content with a subset of properties, you will lose all existing
properties not included in that update.
You should always update resources in the following order:
Fetch current resource.
Make changes to the current resource.
Update the resource by passing the changed resource along with current version number.
This way no unseen changes are overridden and unexpected conflicts are
unlikely to occur.
Note: You can't update any of the sys property fields, including
sys.id.
...so, I guess, I'm doing everything right - taking the post, editing data and sending updated post back.
I tried editing my JSON data to send it without sys fields, but no luck.
I'm stuck, anyone has any ideas what should I proceed with?
Thanks to #whitep4nth3r I was able to solve the problem.
I needed to GET data from the same source I'm trying to PUT it to.
The Authorisation header needed to be replaced with the Personal access token used for PUT request.

Data structure for a family tree with multiple partners and siblings?

I have a very basic family tree structure but I need to figure out how to make it support multiple partners and siblings without as much redundancy.
The base of the entire tree is the person that's creating the tree.
Consider this very simple structure:
{
"name": "Me",
"dob": "1988",
"parents": [
{
"name": "Gina Carano",
"dob": "1967"
},
{
"name": "Genghis Khan",
"dob": "1961"
}
],
"children": [
{
"name": "Tim",
"dob": "1992"
}
]
}
This works nicely but what if I discovered I had a half sibling named Judy (Genghis Khan loved the ladies) and a full sibling named Brian and expanded it to this?
{
"name": "Me",
"dob": "1988",
"parents": [
{
"name": "Gina Carano",
"dob": "1967"
},
{
"name": "Genghis Khan",
"dob": "1961"
}
],
"children": [
{
"name": "Tim",
"dob": "1992"
}
],
"siblings": [
{
"name": "Judy",
"dob": "1987",
"parents": [
{
"name": "Courtney Carano",
"dob": "1965"
},
{
"name": "Genghis Khan",
"dob": "1961"
}
]
},
{
"name": "Brian",
"dob": "1988",
"parents": [
{
"name": "Gina Carano",
"dob": "1967"
},
{
"name": "Genghis Khan",
"dob": "1961"
}
]
}
]
}
This does map my 2 newfound siblings but now I have a bit of redundancy in my data, as Genghis Khan is in 3 different places. I could potentially create a one level list such as this:
[
{ "id": "1", "name": "Me", "dob": "1988", "parents": [2,3], "siblings": [4,5] },
{ "id": "2", "name": "Genghis Khan", "dob": "1961", "children": [1,4,5] },
{ "id": "3", "name": "Gina Carano", "dob": "1967", "children": [1] },
{ "id": "4", "name": "Tim", "dob": "1992", "parents" : [2,3] },
{ "id": "5", "name": "Judy", "dob": "1987", "parents": [2,6] },
{ "id": "6", "name": "Courtney Carano", "dob": "1965", "children": [5] }
]
Would this work out the same way without as much redundancy? And are there any foreseeable circumstances in which there would be any limitations in terms of mapping out multiple partners with children?
Note: I figure if I keep the initial structure, I'd have to add id keys to properly identify that Genghis Khan is the same in all 3 instances.
My end goal is mapping a pedigree tree (probably in d3.js) that is visually going to be in this manner, with a line in the middle between partners going to their children.
So with the dataset above, I'm trying to render:
Almost all genealogy systems have IDs for people, so I wouldn't worry about adding/requiring that.
The traditional way of doing this is to have a Family node type as well as a Person node type. This allows multiple marriages and also gives you a place to connect information like marriage date, marriage place, etc.
person[
{ "id": "p1", "name": "Me", "dob": "1988", "parents": "f3" },
{ "id": "p2", "name": "Genghis Khan", "dob": "1961", "parents": "f1", "spouse_families": ["f2", "f3"] },
{ "id": "p3", "name": "Gina Carano", "dob": "1967", "spouse_families" : ["f3"] },
{ "id": "p4", "name": "Brian", "dob": "1992", "parents" : "f3" },
{ "id": "p5", "name": "Judy", "dob": "1987", "parents": "f2" },
{ "id": "p6", "name": "Courtney Carano", "dob": "1965", "spouse_families": ["f2"] },
{"id": "p7", "name": "Mother of Ghengis"},
{"id": "p8", "name": "Father of Ghengis"},
]
family[
{"id":"f1","marriage date":"", "parents": ["p7", "p8"],"children":["p2"]},
{"id":"f2","marriage date":"", "parents": ["p6", "p2"],"children":["p5"]},
{"id":"f3","marriage date":"", "parents": ["p3","p2"],"children":["p1", "p4"]},
]
This gives you a place to connect all the parents and children together without redundancy and lots of special casing. (Note: I corrected "Tim" to "Brian" in the data structure to match the graphic.)

ACS review condition failure

I'm working in an android app using Titanium appcelerator.
Now i'm trying out ACS REVIEWS .. I'm getting the whole db result , i need to filter by id. For that i tried to put Where condition ..But it doesn't working..
My Json
{
"id": "52ea3eba08a3e5704b330c2a2a",
"rating": 3,
"created_at": "2014-01-30T11:59:54+0000",
"updated_at": "2014-01-30T11:59:54+0000",
"user": {
"id": "52e5f3881356b440b4b09c805",
"created_at": "2014-01-27T05:50:00+0000",
"updated_at": "2014-01-29T04:29:49+0000",
"external_accounts": [
],
"confirmed_at": "2014-01-27T05:50:00+0000",
"username": "Gk",
"role": "j",
"admin": "false",
"custom_fields": {
"phone": "91959454651",
"usertype": "0",
"status": "1",
"ios_deviceid": "",
"country_code": "IN",
"verify_code": "4574",
"verified": "1",
"contact_sms": "1",
"contact_message": "1",
"contact_email": "1",
"contact_phone": "0",
"android_gcmid": "APA91bE0mcScNlXbCENZ2D_9jylgwdwOJ6vYTqnI_Kzqx2lqLWblnn6mT4PJ6iZRNxUGA66Ke7RJ0CKC44DL3mturNs_w3QT7KhTVIWbQE2tJgBHU7gpzB2GG4sFGXL6LiayJ5zEn_AGhxBlw"
}
},
"reviewed_object": {
"type": "Post",
"id": "52e7800313556440b4b0aa134"
},
"custom_fields": {
}
},
{
"id": "52ea3e9d4430d0b1e0c1c16",
"rating": 3,
"created_at": "2014-01-30T11:59:25+0000",
"updated_at": "2014-01-30T11:59:25+0000",
"user": {
"id": "52e8fe464643d0b130b85f5",
"first_name": "Ganesh",
"last_name": "test",
"created_at": "2014-01-29T13:12:38+0000",
"updated_at": "2014-01-29T13:12:38+0000",
"external_accounts": [
],
"confirmed_at": "2014-01-29T13:12:38+0000",
"username": "john",
"role": "r",
"admin": "false"
},
"reviewed_object": {
"type": "Post",
"id": "52e7800343556b4dsfsdfh3434"
},
"custom_fields": {
}
},
]
I want to filter using this id..
"reviewed_object": {
"type": "Post",
"id": "52e7800343556b4dsfsdfh3434"
}
What should i write in my WHERE Condition..
Cloud.Reviews.query({
page : 1,
per_page : 20,
where : {
rating : {
'$gt' : 1.0
},
},
order : "-created_at"
}
i have added my post id condition without where statement ..It worked perfectly..
My Code:
Cloud.Reviews.query({
page :1,
per_page : 20,
post_id : Your Post id
}, function(e) {
if (e.success) {

How do i check my Json

I'm using Titanium Appcelerator to develop an Android application..I getting an error while using 'ACS JSON' .. I trying to use posts query, But i getting different kinds of array ..i need to check is whether the string is available or not before access..
For Example:
"response": {
"posts": [
{
"id": "52e7800340b4b0aa134",
"title": "test",
"created_at": "2014-01-28T10:01:39+0000",
"updated_at": "2014-01-30T11:59:54+0000",
"content": "#hi all",
"reviews_count": 3,
"ratings_count": 3,
"ratings_average": 3.67,
"ratings_summary": {
"5": 1,
"3": 2
},
"user": {
"id": "52e5e87f08a3e70b3309c3e3",
"first_name": "aa",
"last_name": "ss",
"created_at": "2014-01-27T05:02:55+0000",
"updated_at": "2014-01-30T11:58:49+0000",
"external_accounts": [
],
"confirmed_at": "2014-01-27T05:02:55+0000",
"username": "ss",
"role": "a",
"admin": "false"
},
"custom_fields": {
"postedby": "aa",
}
},
{
"id": "52e7908a3e70b3d0a9614",
"title": "bb",
"tags": [
"sdf",
],
"created_at": "2014-01-28T11:46:00+0000",
"updated_at": "2014-01-30T11:09:17+0000",
"content": "#hi# #kWh v #sdf",
"user": {
"id": "52e5e87f08a3e70b3309c3e3",
"first_name": "bb",
"last_name": "bbc",
"created_at": "2014-01-27T05:02:55+0000",
"updated_at": "2014-01-30T11:58:49+0000",
"external_accounts": [
],
"confirmed_at": "2014-01-27T05:02:55+0000",
"username": "b",
"role": "b",
"admin": "false"
},
"custom_fields": {
"postedby": "b"
}
},
See I getting *ratings_count* in my first post..while trying access this inside for loop i getting error..
Now i need to check is whether the string is available or not before access..!
In titanium you can check anything whether it exist or not by using if statment.You can do this
if(ratingcount){
//Do here whatever you want to do
}
Thanks
Try:
for (var i in response.posts) {
post = response.posts[i];
if (post.ratings_count) {
/* Do operations for post with ratings */
} else {
/* Do operations for post without ratings */
}
}
This is pretty basic operation in JavaScript, so before you dive deeper into Titanium it's good to catch up with plain JS before.

Facebook Comments: get comment with more likes

I wont to get the best comment of a page
more like
more old
from:
https://graph.facebook.com/comments/?ids=[YOUR PAGE]
i get this result:
{"[YOUR PAGE]": {
"comments": {
"data": [
{
"id": "10150129443959608_15887865",
"from": {
"name": "Trent Seed",
"id": "614130500"
},
"message": "that house is huge!!",
"created_time": "2011-04-13T10:00:44+0000"
},
{
"id": "10150129443959608_15902791",
"from": {
"name": "Mitch Seed",
"id": "688036079"
},
"message": "wtf this is ridiculous! I cant believe this is actually right by us.",
"created_time": "2011-04-14T02:17:18+0000",
"comments": {
"data": [
{
"id": "10150155952624608",
"from": {
"name": "Ethan Ming",
"id": "592969356"
},
"message": "where does all that flat land come from in los altos HILLS? oh i guess that $100 million also went to removing a small mountain too",
"created_time": "2011-04-14T02:43:57+0000"
},
{
"id": "10150155954519608",
"from": {
"name": "Mitch Seed",
"id": "688036079"
},
"message": "yeah haha thats just straight ridiculous i have ran all through los altos hills i dont remember any land like this haha",
"created_time": "2011-04-14T02:46:40+0000"
},
{
"id": "10150155969784608",
"from": {
"name": "Leila Marie",
"id": "1044030343"
},
"message": "jus copied you haha this is crazy",
"created_time": "2011-04-14T03:13:07+0000"
}
],
"count": 3
}
},
{
"id": "10150129443959608_15932966",
"from": {
"name": "Arthur Lozinski",
"id": "1044030063"
},
"message": "digital sky technologies. remember that name :-D",
"created_time": "2011-04-15T15:42:23+0000"
},
{
"id": "10150129443959608_15962947",
"from": {
"name": "Brian Sator",
"id": "513517991"
},
"message": "I feel like I would get lost in that place.",
"created_time": "2011-04-17T08:03:24+0000",
"likes": 1
},
{
"id": "10150129443959608_16282803",
"from": {
"name": "Jordan McDaniel",
"id": "506352386"
},
"message": "holy shit",
"created_time": "2011-05-04T04:29:27+0000",
"comments": {
"data": [
{
"id": "10150172606879608",
"from": {
"name": "Davey Nicholas",
"id": "1346961549"
},
"message": "\"no plans to move into the mansion\" whos' tryina squat",
"created_time": "2011-05-04T04:35:16+0000"
}
],
"count": 1
}
}
],
"paging": {
"next": "[link]"
}
}
}
}
i wont to get the best message of the json file (or is possible in other way?)
try fql
SELECT id,text,likes FROM comment WHERE object_id=[page_id] order by likes desc
with graphs
https://graph.facebook.com/fql=SELECT+id,text,likes+FROM+comment+WHERE+object_id=[page_id]+order+by+likes+desc
see more about fql