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
Related
How to convert below json to valid json
{
"attribute_id":"r2d2",
"attribute_values":[
WrappedArray( [
5 b1ed5df4a0330a13a3b6f4c,
{
"L0":{
"name":"ENTERTAINMENT",
"id":"20000"
},
"L1":{
"name":"VIDEO GAMES BOOKS AND OTHER MEDIA",
"id":"26000"
},
"L2":{
"name":"MEDIA",
"id":"26001"
},
"L3":{
"name":"BOOKS",
"id":"26100"
},
"L4":{
"name":"BOOKS MISC L4",
"id":"26800"
}
},
PRIORITY_OTHERS,
1536662873016,
26800
] )
],
"bu":"0",
"item_id":"705024754",
"last_updated_by":"QARTH",
"mart":"0",
"published_at":"1536662873017",
"source":"RAMP",
"timestamp":"1536662873016",
"vertical":"0",
"wpid":"7HX1KF1N9W9Y"
}
Valid json should be this
{
"attribute_id": "r2d2",
"attribute_values": [
[{
"L0": {
"name": "ENTERTAINMENT",
"id": "20000"
},
"L1": {
"name": "VIDEO GAMES BOOKS AND OTHER MEDIA",
"id": "26000"
},
"L2": {
"name": "MEDIA",
"id": "26001"
},
"L3": {
"name": "BOOKS",
"id": "26100"
},
"L4": {
"name": "BOOKS MISC L4",
"id": "26800"
}
},
"PRIORITY_OTHERS",
1536662873016,
26800
]
],
"bu": "0",
"item_id": "705024754",
"last_updated_by": "QARTH",
"mart": "0",
"published_at": "1536662873017",
"source": "RAMP",
"timestamp": "1536662873016",
"vertical": "0",
"wpid": "7HX1KF1N9W9Y"
}
Could you please post your sql if this does not answer your question?
The json below is the response I get from the server for requesting /id/albums, but I want to use that data to get the link to the album that has all the pictures in json format. The "link" field provided is to the actual desktop site, but I need the json. How would I use the json data provided (below) to send a request to graph.facebook.com to get the pictures within the corresponding album in json format?
{
"data": [
{
"id": "150228731810007",
"from": {
"name": "James McMahon",
"id": "100004686423103"
},
"name": "Profile Pictures",
"link": "https://www.facebook.com/album.php?fbid=150228731810007&id=100004686423103&aid=1073741831",
"cover_photo": "150228735143340",
"count": 2,
"type": "profile",
"created_time": "2013-03-15T05:29:24+0000",
"updated_time": "2013-11-09T17:12:36+0000",
"can_upload": false
},
{
"id": "233767233456156",
"from": {
"name": "James McMahon",
"id": "100004686423103"
},
"name": "Mobile Uploads",
"link": "https://www.facebook.com/album.php?fbid=233767233456156&id=100004686423103&aid=1073741838",
"type": "mobile",
"created_time": "2013-11-09T17:12:30+0000",
"updated_time": "2013-11-09T17:12:30+0000",
"can_upload": false
},
{
"id": "206255352874011",
"from": {
"name": "James McMahon",
"id": "100004686423103"
},
"name": "Aug. 17th, 2013",
"description": "Day with some of the Family",
"link": "https://www.facebook.com/album.php?fbid=206255352874011&id=100004686423103&aid=1073741837",
"cover_photo": "206255402874006",
"count": 8,
"type": "normal",
"created_time": "2013-08-17T21:24:12+0000",
"updated_time": "2013-08-17T21:24:36+0000",
"can_upload": false,
"likes": {
"data": [
{
"id": "1774907390",
"name": "Ashley Carter"
},
{
"id": "646440613",
"name": "Mitzy Lanthier"
},
{
"id": "1801948293",
"name": "Calvin Carter"
},
{
"id": "100000653918655",
"name": "Kimberly Lane Lirette"
}
],
"paging": {
"cursors": {
"after": "MTAwMDAwNjUzOTE4NjU1",
"before": "MTc3NDkwNzM5MA=="
}
}
}
},
{
"id": "150230918476455",
"from": {
"name": "James McMahon",
"id": "100004686423103"
},
"name": "Cover Photos",
"link": "https://www.facebook.com/album.php?fbid=150230918476455&id=100004686423103&aid=1073741833",
"cover_photo": "202581716574708",
"count": 4,
"type": "cover",
"created_time": "2013-03-15T05:43:31+0000",
"updated_time": "2013-08-08T17:26:35+0000",
"can_upload": false
},
{
"id": "158017154364498",
"from": {
"name": "James McMahon",
"id": "100004686423103"
},
"name": "Timeline Photos",
"link": "https://www.facebook.com/album.php?fbid=158017154364498&id=100004686423103&aid=1073741834",
"cover_photo": "179650435534503",
"count": 10,
"type": "wall",
"created_time": "2013-04-07T14:04:04+0000",
"updated_time": "2013-06-12T23:28:45+0000",
"can_upload": false
},
{
"id": "178309025668644",
"from": {
"name": "James McMahon",
"id": "100004686423103"
},
"name": "U.S.Navy D.E.P.",
"description": "Was a pretty fun day. We were out there helping restore this World War 2 Destroyer.",
"link": "https://www.facebook.com/album.php?fbid=178309025668644&id=100004686423103&aid=1073741835",
"cover_photo": "178309055668641",
"count": 4,
"type": "normal",
"created_time": "2013-06-10T00:32:45+0000",
"updated_time": "2013-06-10T00:33:49+0000",
"can_upload": false,
"likes": {
"data": [
{
"id": "100000651398529",
"name": "Jennifer Manuel Hyatt"
},
{
"id": "1801948293",
"name": "Calvin Carter"
},
{
"id": "1522740127",
"name": "Bliss Reane Kinder"
}
],
"paging": {
"cursors": {
"after": "MTUyMjc0MDEyNw==",
"before": "MTAwMDAwNjUxMzk4NTI5"
}
}
}
},
{
"id": "150228468476700",
"from": {
"name": "James McMahon",
"id": "100004686423103"
},
"name": "Untitled Album",
"description": "03112013",
"link": "https://www.facebook.com/album.php?fbid=150228468476700&id=100004686423103&aid=1073741830",
"cover_photo": "150228475143366",
"count": 1,
"type": "normal",
"created_time": "2013-03-15T05:27:54+0000",
"updated_time": "2013-03-15T05:28:17+0000",
"can_upload": false
}
],
"paging": {
"cursors": {
"after": "MTUwMjI4NDY4NDc2NzAw",
"before": "MTUwMjI4NzMxODEwMDA3"
}
}
}
Response received in 237 ms
You have the id field- that's the album-id
So, you can create the link by yourself, just like this-
https://graph.facebook.com/<ALBUM-ID>/photos
from this you can fetch all the photos of a particular album (but remember that you'll need the access token- of-course)
https://graph.facebook.com/<ALBUM-ID>/photos?access_token=<ACCESS-TOKEN>
I have this JSON data from my facebook page:
{
"data": [
{
"id": "1234567890_0987654321",
"from": {
"name": "My Facebook Page",
"category": "Personal blog",
"id": "1234567890"
},
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/1234567890/posts/0987654321"
},
{
"name": "Like",
"link": "http://www.facebook.com/1234567890/posts/0987654321"
},
{
"name": "Action Name",
"link": "http://example.com/"
}
],
"message": "This post discusses something about Javascript.",
"name": "A post about javascript.",
"link": "http://example.com/",
"caption": "JavaScript",
"description": "Something telling about the post.",
"created_time": "2012-10-09T03:35:22+0000"
},
{
"id": "1234567890_0987654321",
"from": {
"name": "My Facebook Page",
"category": "Personal blog",
"id": "1234567890"
},
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/1234567890/posts/0987654321"
},
{
"name": "Like",
"link": "http://www.facebook.com/1234567890/posts/0987654321"
},
{
"name": "Action Name",
"link": "http://example.com/"
}
],
"message": "This post discusses something about CSS.",
"name": "A post about CSS.",
"link": "http://example.com/",
"caption": "CSS",
"description": "Something telling about the post.",
"created_time": "2012-10-09T03:35:22+0000"
}
]
}
Is there anyway I can do this with FQL where I will just have all the posts with "caption": "JavaScript"? I want to sort my post by category and my keywords are inside the "caption" attribute.
IF you want to get feeds short by order you need to use FQL
here is sample one of them
SELECT post_id, actor_id, target_id,description, message FROM stream WHERE source_id = me() order by description
Thank you to all who responded my question. I think I got the answer to my question already.
I will just do this query on FQL to get all posts with "caption": "Javascript":
SELECT actor_id,message,attachment FROM stream WHERE source_id=1234567890 AND attachment.caption="Javascript"
I guess this is a big ask. Using PHP I grab this Facebook Graph API json feed json feed link
{
"data": [
{
"id": "10369058551_10150645263758552",
"from": {
"name": "Land Rover",
"category": "Cars",
"id": "10369058551"
},
"message": "This week's Land Rover photo of the week is by Rodrigo Beja. Don't forget to submit your best photos each week to get featured.",
"link": "http://www.facebook.com/photo.php?fbid=10150645263678552&set=a.443106273551.221975.10369058551&type=1",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v1/yz/r/StEh3RhPvjk.gif",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/10369058551/posts/10150645263758552"
},
{
"name": "Like",
"link": "http://www.facebook.com/10369058551/posts/10150645263758552"
}
],
"privacy": {
"description": "United Kingdom",
"value": "CUSTOM"
},
"type": "photo",
"object_id": "10150645263678552",
"created_time": "2012-02-03T17:19:03+0000",
"updated_time": "2012-02-03T22:32:28+0000",
"likes": {
"data": [
{
"name": "Mandy Elder",
"id": "100000250758731"
}
],
"count": 85
},
"comments": {
"data": [
{
"id": "10369058551_10150645263758552_6835532",
"from": {
"name": "John Sharp",
"id": "652940638"
},
"message": "This photo was used as part of the g4 challenge publicity photo pack around 2005-6 \nI remember because at the time I used it as a profile pic on msn \n\nAwesome photo - sums it up perfectly - I love it!!",
"created_time": "2012-02-03T21:39:48+0000"
},
{
"id": "10369058551_10150645263758552_6835852",
"from": {
"name": "Kathryn Piddington",
"id": "777370532"
},
"message": "Mud is good for the soul :)",
"created_time": "2012-02-03T22:32:28+0000"
}
],
"count": 14
}
},
{
"id": "10369058551_355476307803889",
"from": {
"name": "Land Rover",
"category": "Cars",
"id": "10369058551"
},
"message": "Click below to watch the new Range Rover Sport advert and catch up on the latest Land Rover and Range Rover news in this week\u2019s round-up. ",
"picture": "http://external.ak.fbcdn.net/safe_image.php?d=AQAx7xz602rfhyIn&w=90&h=90&url=http\u00253A\u00252F\u00252Fblog.landrover.com\u00252Fwp-content\u00252Fuploads\u00252F12my_rrs_044_LowRes.jpg",
"link": "http://blog.landrover.com/vehicles/the-land-rover-and-range-rover-weekly-19-3578.html#axzz1lKthI4F1",
"name": "The Land Rover and Range Rover Weekly 19 | Land Rover Blog",
"caption": "blog.landrover.com",
"description": "In this week\u2019s round-up of all things Land Rover and Range Rover, the new Range Rover Sport advert, Which? figures reveal the running costs of the Range Rover Evoque in comparison with competitors and a history of Land Rover narrated by Ranulph Fiennes.",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v1/yD/r/aS8ecmYRys0.gif",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/10369058551/posts/355476307803889"
},
{
"name": "Like",
"link": "http://www.facebook.com/10369058551/posts/355476307803889"
}
],
"privacy": {
"description": "United Kingdom",
"value": "CUSTOM"
},
"type": "link",
"created_time": "2012-02-03T16:44:42+0000",
"updated_time": "2012-02-03T16:44:42+0000",
"likes": {
"data": [
{
"name": "Steve Nesbitt",
"id": "533982936"
}
],
"count": 10
},
"comments": {
"count": 0
}
},
{
"id": "10369058551_10150642499593552",
I'd like to the top level items to a mysql table, then each sub level to anaother table keeping a key / link between each table and then any sub level of a sublevel and linking this too. Is this possible?
I have got as far as this:-
$page = file_get_contents($url);
$json_output = json_decode($page, true);
I can't figure out how to loot hrough each row and add teh data to a Mysql table.
Thanks for your help in advance
Jonathan
Try to loop it as array then make sql query. Each array you put a unique key (for top level item). So, you can use your top level key to sub level foreign key..
JSON is very popular among social network sites.
I have been searching tools for analyzing JSON and found some good tools for viewing but they do not meet my needs. (like http://jsonviewer.codeplex.com/)
I need to search and filter the data by specific a field and then get some value from another specific field.
Can you suggest a tool or a way to view my JSON data easily?
sample data:
{
"data": [
{
"id": "141816652602643",
"from": {
"name": "Deval Agrifarman",
"id": "896085636"
},
"message": "yang belum bisa berhenti ngerokok silahkan dilihat... kalo ga bisa donlot mampir aja ke rumah bawa camilan :D",
"picture": "http://external.ak.fbcdn.net/safe_image.php?d=AQC3wb7_yd8fdv64&w=130&h=130&url=http\u00253A\u00252F\u00252Fi1.ytimg.com\u00252Fvi\u00252FDiyWK3fzTpA\u00252Fhqdefault.jpg",
"link": "http://www.youtube.com/watch?v=DiyWK3fzTpA",
"name": "Sex, Lies & Cigarettes': Vanguard Sneak Peek (Indonesia Subtitle-Full)",
"description": "Fakta mengenai Industri dan bisnis Rokok diIndonesia, Penetrasi Rokok dalam masyarakat Indonesia.. Dalam Konferensi Dunia untuk Tembakau 2010 Koresponden Chr...",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v1/yD/r/aS8ecmYRys0.gif",
"created_time": "2012-01-26T15:03:21+0000"
},
{
"id": "109379672518544",
"from": {
"name": "Deval Agrifarman",
"id": "896085636"
},
"message": "kesannya kok kayak aku yang minta ke monyet nya yah wkwkwkwk...",
"link": "http://www.facebook.com/photo.php?fbid=107424555941677&set=a.101882006495932.4636.100000224005368&type=1",
"name": "~KeBaB~",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v1/yD/r/aS8ecmYRys0.gif",
"created_time": "2012-01-23T15:33:45+0000",
"comments": {
"data": [
{
"id": "109379672518544_32659",
"from": {
"name": "Dhanank Perdhana",
"id": "1243815675"
},
"message": "Deval: \"Mbah, tolong diramal dong garis tangan saya...\"\nMbak Nyemot: \"Hooo.. kamu ini ngga' cocok jadi pejabat.. Nanti kamu pasti pengen cepet2 beli Bentley.. \"\n\n...huehuehue... :P",
"can_remove": true,
"created_time": "2012-01-23T15:39:34+0000",
"likes": 3,
"user_likes": true
},
{
"id": "109379672518544_32663",
"from": {
"name": "Alex Zar",
"id": "1378608838"
},
"message": "klo sodara mmg harus saling berbagi...",
"can_remove": true,
"created_time": "2012-01-23T15:42:19+0000"
},
{
"id": "109379672518544_32682",
"from": {
"name": "Deval Agrifarman",
"id": "896085636"
},
"message": "Dhanank Perdhana baiklah mbah aku akan jadi pejabat saja... biar punya jaguar... xixixi...\n\nAlex Zar weleh... sodara mu toh? kirain syapa :D xixixi...",
"message_tags": [
{
"id": "1243815675",
"name": "Dhanank Perdhana",
"offset": 0,
"length": 16
},
{
"id": "1378608838",
"name": "Alex Zar",
"offset": 92,
"length": 8
}
],
"can_remove": true,
"created_time": "2012-01-23T15:46:13+0000"
},
{
"id": "109379672518544_33010",
"from": {
"name": "Ali M. Fauzi",
"id": "1248947710"
},
"message": "\"Seharusnya tangan diatas lebih baik dari tangan dibawah.\" Kira2 klo kondisinya kayak gitu gmn ya? :-) :)",
"can_remove": true,
"created_time": "2012-01-23T17:11:03+0000"
},
{
"id": "109379672518544_33012",
"from": {
"name": "Ali M. Fauzi",
"id": "1248947710"
},
"message": "\"Seharusnya tangan diatas lebih baik dari tangan dibawah.\" Kira2 klo kondisinya kayak gitu gmn ya? :-) :)",
"can_remove": true,
"created_time": "2012-01-23T17:11:17+0000"
},
{
"id": "109379672518544_34880",
"from": {
"name": "Deval Agrifarman",
"id": "896085636"
},
"message": "kesannya kayak DPR sekarang... tangannya di atas tapi nyolong dari yang ada di bawah... :D wkwkwkwk...",
"can_remove": true,
"created_time": "2012-01-24T03:07:16+0000"
},
{
"id": "109379672518544_35753",
"from": {
"name": "Maruko Chan",
"id": "100001798922313"
},
"message": "LOL! iya.. hahaha",
"can_remove": true,
"created_time": "2012-01-24T09:14:24+0000"
},
{
"id": "109379672518544_38576",
"from": {
"name": "Y.i. Kusumawati",
"id": "1334087290"
},
"message": "sbenernya monyetnya yang mana",
"can_remove": true,
"created_time": "2012-01-25T00:01:56+0000"
},
{
"id": "109379672518544_39568",
"from": {
"name": "Ali M. Fauzi",
"id": "1248947710"
},
"message": "Nah.... Loh... pertanyaan bagus tuh....",
"can_remove": true,
"created_time": "2012-01-25T06:10:11+0000"
},
{
"id": "109379672518544_39665",
"from": {
"name": "Ajungo Toriyama",
"id": "1266357019"
},
"message": "Deval Agrifarman : salim dulu....sama kakak.....",
"message_tags": [
{
"id": "896085636",
"name": "Deval Agrifarman",
"offset": 0,
"length": 16
}
],
"can_remove": true,
"created_time": "2012-01-25T07:13:39+0000"
}
],
"paging": {
"next": "https://graph.facebook.com/109379672518544/comments?limit=25&method=GET&metadata=true&format=json&callback=___GraphExplorerAsyncCallback___&access_token=AAACEdEose0cBAKn8Nfv307rHgjdP9l9usbDj1KbQlzotoQDs6zuQEcxioPm73R3h1ZABBiNQyPG9iukYZAxjnxwmd6ZCNuYdkkKQ7KA4QZDZD&offset=25&__after_id=109379672518544_39665"
}
}
},
{
"id": "335701516450154",
"from": {
"name": "Deval Agrifarman",
"id": "896085636"
},
"message": "selamat tahun baru lagi yah :D sori nggak sempet bikin kartu ucapan :)",
"link": "http://www.facebook.com/photo.php?fbid=10150484907061432&set=a.170757796431.134250.152798801431&type=1",
"name": "Wall Photos",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v1/yD/r/aS8ecmYRys0.gif",
"created_time": "2012-01-23T11:36:19+0000"
}
],
"paging": {
"previous": "https://graph.facebook.com/896085636/links?limit=3&format=json&since=1327590201&__paging_token=141816652602643&__previous=1",
"next": "https://graph.facebook.com/896085636/links?limit=3&format=json&until=1327318579&__paging_token=335701516450154"
}
}
what i need is for example:
getting values of 'link' from 'created_time' in january
getting values of 'message' and 'picture' plus all 'name' and 'message' inside 'comments' if there are any
I mostly use this tool http://codedestine.com/json-editor.html It has feature to add date and its drag and drop UI makes it easy to construct json. It will show you json in object view, then you can select any node and get its data and even can modify it.
If Java tools are OK, look at JSONPath, article http://goessner.net/articles/JsonPath/
Data may be interactively found and extracted out of JSON structures on the client without special scripting.
There is also JSONselect http://jsonselect.org/#tryit I have found today.
JSONSelect is an experimental selector language for JSON.
It makes it easy to access data in complex JSON documents.
It feels like CSS.
Code on GitHub https://github.com/lloyd/JSONSelect
Last updated a year ago