facebook, how to get more information concerning the likes? - facebook

i am grabbing the likes of my friends, but i also want to grab the links that are found in that likes.
When you like something the like on your wall will point to something, whatever u liked. I am talking about all those links.
edit:
the response i get right now looks something like:
{
"data": [
{
"name": "Seam Legging - Shooting Star",
"category": "Product/service",
"id": "114310318626160",
"created_time": "2011-06-15T22:26:18+0000"
},
{
"name": "Junior's 535\u2122 Legging - Seaport Blue",
"category": "Product/service",
"id": "146626898728947",
"created_time": "2011-06-15T22:26:17+0000"
},
{
"name": "Singer Needed For Pleasure Band CA Music Vocals Los Angeles, CA auditions Modeling Acting Auditions & Casting Calls ExploreTalent modeling audition america next top model",
"category": "Website",
"id": "122740287810745",
"created_time": "2011-06-15T19:06:13+0000"
},
{
"name": "Looking for singers R/B Britney type K P Music Vocals Los Angeles, CA auditions Modeling Acting Auditions & Casting Calls ExploreTalent extras acting extra",
"category": "Website",
"id": "130850386995940",
"created_time": "2011-06-15T19:06:12+0000"
},......
edit2:
i have been trying to use FQL. but i still dont get the links from inside likes:
her is my code so far
<?php
$facebook = new Facebook(array(
'appId' => $client_id,
'secret' => $client_secret,
'cookie' => true,
));
$session = $facebook->getSession();
$likelink = $facebook->api(array( 'method' => 'fql.query', 'query' => 'SELECT likes FROM stream WHERE source_id ='.$myself.'', ));
print_r($likelink);
?>

After retrieving the list of likes you have, you then need to go through them, get the ID and open up:
https://graph.facebook.com/ID
Which will give you more details regarding that specific item which you liked. For example for the first item in your data:
https://graph.facebook.com/114310318626160
{
"id": "114310318626160",
"name": "Seam Legging - Shooting Star",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/50281_114310318626160_1881220_s.jpg",
"link": "http://r.levi.com/product/index.jsp?productId=4068748",
"likes": 115,
"category": "Product/service",
"website": "http://r.levi.com/product/index.jsp?productId=4068748",
"description": "Buy Seam Legging - Shooting Star - Top-stitched seams at the leg give this super-skinny fit just the right amount of detail - and slims its look, too. Its four pockets keep it comfortable."
}
And from there, you can probably guess that the link is the actual link to the liked item. Do note that not all items liked are some websites, but they can be for example Facebook pages for example:
https://graph.facebook.com/108905269168364
{
"id": "108905269168364",
"name": "Conan O'Brien Presents: Team Coco",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/211060_108905269168364_696236_s.jpg",
"link": "http://www.facebook.com/teamcoco",
"likes": 1639441,
"category": "Tv show",
"website": "www.teamcoco.com\n",
"username": "teamcoco",
"description": "Welcome to the official Team Coco Facebook page! Yes, imagine for a moment, an alternate reality in which Conan O'Brien and his brethren can finally be experienced as they were always meant to be: shoehorned into the madcap blue and white webpage templates of Mr. Mark Zuckerberg! This is that reality! Let us live the adventure together, fearless Socialnauts!\n\nWhile this page is \"official\", it's here to be YOUR playground. Anyone can post here, so go crazy; we only ask that posts remain on-topic. If you're a purveyor of spam, smut, or unkindness, kindly die -- as you will be banned from this page. \n\nBy the way, you can also find Conan & Team Coco on other, similarly awesome corners of the internets:\n\nteamcoco.com\ntwitter.com/teamcoco\nteamcoco.tumbler.com\nyoutube.com/teamcoco\nfoursquare.com/teamcoco\nflickr.com/teamcoco\n\nToodles,\n\n- Your Pals \u0040 Team Coco",
"genre": "Comedy",
"network": "TBS",
"checkins": 3
}
But in that case, the link defines the url to the Facebook page.

Related

In FaceBook Graph API v2.4, how can I include pictures/icons of the posts in the JSON feed?

I'm able to get JSON posts feed for a Public Group Page in FaceBook. However, the feed is limited to the following:
{
"data": [
{
"message": "RT Ad Age: Creatives rejoice! The need for speed in digital is putting copy testing under fire http://buff.ly/1NCNUYm",
"created_time": "2015-09-16T19:17:22+0000",
"id": "100893736659527_876911945724365"
},
{
"message": "Smart Design Means Treating Your Users Like Friends.",
"created_time": "2015-09-15T19:17:07+0000",
"id": "100893736659527_876382499110643"
},
{
"message": "Amazon Puts Another Nail in Flash\u2019s Coffin http://buff.ly/1NzwFal (via Digiday)",
"created_time": "2015-09-14T17:25:52+0000",
"id": "100893736659527_875881985827361"
},
{
"message": "Is Belvedere Vodka Good Enough For James Bond?",
"created_time": "2015-09-11T19:17:14+0000",
"id": "100893736659527_874377899311103"
},
{
"message": "RT MailChimp: Our GIPHY integration makes it easy to upload GIFs into your campaign. Exciting, right? http://buff.ly/1JQChqz",
"created_time": "2015-09-10T19:17:14+0000",
"id": "100893736659527_873864092695817"
}
}
I'm able to get the message text, created_time, and id. How can I include pictures/icons of the post?
After #WizKid responded above, this what worked for me: https://graph.facebook.com/v2.4/[page-id]/feed?access_token=[access_token]&fields=picture,id,message

Facebook Graph API Get Comments outside of Wall

I have been learning how the Facebook Graph API works for a while and managed to get the info out of the "me" , "me/likes" and "me/posts" edges,
My question is in regard to the "me/posts" edge; it retrieves all the posts on the user's wall only not the posts/comments he made on another page and or a friends wall, all i get is a "type": "status" JSON node with no actual "message": "" node in the JSON entry saying "XYZ commented on a status."
Example:
{
"id": "<USER_ID>_<POST_ID>",
"from": {
"id": "<USER_ID>",
"name": "XYZ"
},
"story": "XYZ commented on a status.",
"story_tags": {
"0": [
{
"id": "<USER_ID>",
"name": "XYZ",
"offset": 0,
"length": 3,
"type": "user"
}
]
},
"privacy": {
"value": ""
},
"type": "status",
"created_time": "2014-11-11T22:18:25+0000",
"updated_time": "2014-11-11T22:18:25+0000"
}
As you can see there is no "message": "value" node included in the JSON returned its just informing me that he made a comment but i need the value or the message of that comment !
Now, failed attempts i have gone through so far includes:
1. Requesting <PAGE_ID/FRIEND_ID>/posts: I'm unaware of the
PAGE_ID/FRIEND_ID with the information i have from the previous
JSON.
2. Requesting the <POST_ID> returned: As explained it
doesn't work and for my case a 100% of the time.
So is there an official way to know what the user wrote on fan page or on a comment he made on a friend's public wall through the Facebook Graph API or even the FQL API ?
Thanks.
This is a long standing bug in Facebook, probably older than two years.
https://developers.facebook.com/bugs/648986871793611/ https://developers.facebook.com/bugs/522743067756848/
Facebook doesn't seem interested in fixing this.
There is no official way to do this until Facebook fixes the incomplete data.

How to check if the facebook post is commentable

I am fetching the Facebook news feeds through API. User can comment on a post from website. but some posts doesnot allow the comment like Like Stories, add friend stories, change profile pic stories etc
How I can check that if the post allow the comment or not
The actions property of the post when you retrieve it from the API will show if the current (whose access_token you're using) user can like or comment on the post, e.g.
/20531316728_167191526758558
Contains:
{
"id": "20531316728_167191526758558",
"from": {
"name": "Facebook",
"category": "Product/service",
"id": "20531316728"
},
"message": "Find your polling place on Facebook at http://bit.ly/Fbppl and then watch the nation vote in real time.",
"picture": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQCD6BNbTzxhmwEq&w=90&h=90&url=https%3A%2F%2Fs3.amazonaws.com%2FFacebookHackers-production%2Fissue4_data%2Fissue4_fb_og.png",
"link": "http://www.facebookstories.com/vote",
"name": "America Votes 2012",
"caption": "www.facebookstories.com",
"description": "Watch the nation vote in real time.",
"icon": "https://s-static.ak.facebook.com/rsrc.php/v2/yN/x/aS8ecmYRys0.gif",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/20531316728/posts/167191526758558"
},
{
"name": "Like",
"link": "https://www.facebook.com/20531316728/posts/167191526758558"
}
],
// (and more properties which aren't relevant

How to tell whether a URL is a Facebook Page or Profile?

I use FQL to validate whether a user-submitted URL is a Facebook Page or Profile as seen here: Validate a Facebook page URL
This previously worked. When I'd send a URL like facebook.com/zuck or facebook.com/cocacola it would return a normalized_url with profile.php or /pages/. Now, it just returns the same URL: e.g. facebook.com/zuck.
Is this a Facebook API bug? Or is there another way to solve this problem?
Perhaps use the Facebook Graph API and look for properties that only a page would have. For example the Coca Cola API return (see below) returns likes which only a page would have, you could also look for a description, website, about and location but don't rely on just one. Conversely, a person will tend to have a first_name and last_name. Use these in unison to determine whether the username is a person or page.
http://graph.facebook.com/zuck
{
"id": "4",
"name": "Mark Zuckerberg",
"first_name": "Mark",
"last_name": "Zuckerberg",
"link": "https://www.facebook.com/zuck",
"username": "zuck",
"gender": "male",
"locale": "en_US"
}
http://graph.facebook.com/cocacola
{
"id": "40796308305",
"name": "Coca-Cola",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/174560_40796308305_2093137831_s.jpg",
"link": "https://www.facebook.com/coca-cola",
"likes": 41519873,
"cover": {
"cover_id": "10150682306963306",
"source": "http://a7.sphotos.ak.fbcdn.net/hphotos-ak-snc7/s720x720/416803_10150682306963306_40796308305_9337341_812683101_n.jpg",
"offset_y": 0
},
"category": "Food/beverages",
"is_published": true,
"website": "http://www.coca-cola.com",
"username": "coca-cola",
"founded": "1886",
"description": "Created in 1886 in Atlanta, Georgia, by Dr. John S. Pemberton, Coca-Cola was first offered as a fountain beverage at Jacob's Pharmacy by mixing Coca-Cola syrup with carbonated water. \n\nCoca-Cola was patented in 1887, registered as a trademark in 1893 and by 1895 it was being sold in every state and territory in the United States. In 1899, The Coca-Cola Company began franchised bottling operations in the United States. \n\nCoca-Cola might owe its origins to the United States, but its popularity has made it truly universal. Today, you can find Coca-Cola in virtually every part of the world.",
"about": "The Coca-Cola Facebook Page is a collection of your stories showing how people from around the world have helped make Coke into what it is today.",
"location": {
"latitude": 53.71282619,
"longitude": -1.51214516
},
"checkins": 92,
"talking_about_count": 383754
}
I'm facing the same problem and I've decided to watch the "is_published" or "likes" fields.

Facebook Graph API - Get like count on page/group photos

I've been testing graph API and ran into a problem. How can I get like count from photos of a page/group?
I'm administrator/creator of a group. When entering in https://developers.facebook.com/tools/explorer/ certain photo ID from that group it brings almost all data, even comments, but not the like count. For like part it needs (according to docs) access token despite the fact that anyone can access that info.
How to get access token of my page/group with required permissions and how to use it to get info I need?
If possible I would like to get JSON from a single address if it is possible.
This is possible with a page (even without an access token!) and here's how:
Visit the page on the graph
Get the page's id by going to the page's url:
https://www.facebook.com/pages/platform/19292868552
The number on the end of the URL is the page's id. Take that id and use it with the graph explorer (here) or just visit it directly.
Visit the page's albums
Now appending albums to that url will give you all the albums the page has, including wall photos:
https://graph.facebook.com/19292868552/albums
The output looks like this:
{
"data": [
{
"id": "10150160810478553",
"from": {
"name": "Facebook Platform",
"category": "Product/service",
"id": "19292868552"
},
"name": "Bringing Operation Developer Love to Europe",
"description": "Blog post: http://developers.facebook.com/blog/post/479\n\nVideos and presentations uploaded here: http://developers.facebook.com/videos/",
"location": "Berlin, Paris, London",
"link": "https://www.facebook.com/album.php?fbid=10150160810478553&id=19292868552&aid=285301",
"cover_photo": "10150160811078553",
"count": 32,
"type": "normal",
"created_time": "2011-04-06T23:05:44+0000",
"updated_time": "2011-04-06T23:33:20+0000",
"comments": {
..... etc ....
Selecting an album
For each object in the data array there is an id and a name. Using these two fields you can select the album that contains the photos you want. The first album in this result is "Bringing Operation Developer Love to Europe". Lets look at this albums photos.
Seeing Photos
If you've followed the answer up to this point the next step should be fairly obvious. Use the id for the album you want and append photos to the graph url:
https://graph.facebook.com/10150160810478553/photos
Seeing a Photo's likes
Much like selecting an album, simply use an id in the output of the above step and append likes to the url to see a photos likes:
https://graph.facebook.com/10150160813853553/likes
Output:
{
"data": [
{
"id": "1163036945",
"name": "Aditya Pn"
},
{
"id": "1555885347",
"name": "Nadin M\u00f6ller"
},
{
"id": "100001643068103",
"name": "Umut Ayg\u00fcn"
},
{
"id": "100000165334510",
"name": "Alessandra Milfont"
},
{
"id": "100001472353494",
"name": "Sayer Mohammad Naz"
},
{
"id": "1051008973",
"name": "Jenson Daniel Chambi"
},
{
"id": "100000233515895",
"name": "Ruby Atiga"
},
Using this output you can simply count the number of entries in the data array to get the like count.
Note that all of this is possible from using the graph explorer by clicking on ids in the output box and the connections sidebar (except for the last /likes connection, which will hopefully be added soon. I hope this helps. Also, you do not need an access token to do any of this because pages are public. Hope this helps!
You can get the comments/likes count without having to paginate through all likes by using the fields parameter in combination with likes.limit(1).summary(true). For example, a search api query for pizza below will give you all public posts and their likes count summarized:
https://graph.facebook.com/search?q=pizza&type=post&fields=id,name,likes.limit(1).summary(true)
results (truncated):
{
"data": [
{
"id": "47883936273_659693910762305",
"name": "Instagram",
"created_time": "2014-02-16T01:15:29+0000",
"likes": {
"data": [
{
"id": "100002243084532",
"name": "Yvette Martin"
}
],
"paging": {
"cursors": {
"after": "MTAwMDAyMjQzMDg0NTMy",
"before": "MTAwMDAyMjQzMDg0NTMy"
},
"next": "https://graph.facebook.com/47883936273_659693910762305/likes?limit=1&summary=1&after=MTAwMDAyMjQzMDg0NTMy"
},
"summary": {
"total_count": 13682
}
}
},
{
"id": "136336876521150_314001148754721",
"name": "Pizza Box Turns into Plates & Storage Unit!",
"created_time": "2014-02-15T21:20:00+0000",
"likes": {
"data": [
{
"id": "100005373008864",
"name": "Liliana Campoli"
}
],
"paging": {
"cursors": {
"after": "MTAwMDA1MzczMDA4ODY0",
"before": "MTAwMDA1MzczMDA4ODY0"
},
"next": "https://graph.facebook.com/136336876521150_314001148754721/likes?limit=1&summary=1&after=MTAwMDA1MzczMDA4ODY0"
},
"summary": {
"total_count": 2792
}
}
}
/me/feed returns a LIKES field
I used a solution where I simply find the number of items in the array which display LIKES
Object.keys(item.likes.data).length
This returns the "length" of an object -- which is equal to the number of likes.
http://graph.facebook.com/223766074374957
there is a likes property in the response
{
"name": "Bejeweled Blitz",
"is_published": true,
"website": "https://apps.facebook.com/bejeweledblitz/",
"username": "bejeweledblitz",
"products": "Bejeweled Blitz\nBejeweled\nPlants vs. Zombies\nPeggle\nZuma\nChuzzle\nBookworm Adventures\n \nFor a complete list, please visit www.popcap.com\n ",
"about": "We're the award-winning hit, Bejeweled Blitz! The lightning-fast puzzle game where you have just 60-seconds to match as many gems as you can! Start Blitzing now!",
"general_info": "Speed is the name of the game in Bejeweled Blitz! Bejeweled Blitz is a speedier take on the classic Bejeweled match-3 gem game mechanic. Your goal is to make as many matches as you can in 60-seconds to really make your score soar! But you won't be going it alone! There are special ways to enhance your Bejeweled Blitz game - like Boosts (power-ups like Scrambler, which moves all the gems around the board or +5 seconds, to add 5 seconds more gem-matching time!) and the popular, Rare Gems. Rare Gems are like extra-special power-ups that can REALLY take your game to the next level!",
"talking_about_count": 22487,
"category": "App page",
"id": "223766074374957",
"link": "https://www.facebook.com/bejeweledblitz",
"likes": 5796324,
"cover": {
"cover_id": 383412771743619,
"source": "http://sphotos-c.ak.fbcdn.net/hphotos-ak-ash4/s720x720/417018_383412771743619_1056862875_n.jpg",
"offset_y": 0
}
}