View post photo from friends using facebook graph api - facebook

I want to make my app to become less boring, one way to do it is by showing post photos from friends on the home tab. I manage to do some of it by using graph api.
I am using this graph to view my friend activities
https://graph.facebook.com/me/home?limit=25&access_token=erqaer
result:
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/157108_525475649_53898163_q.jpg",
"link": "http://www.facebook.com/sample",
"type": "link",
I get to get this photo by getting the picture data, but on post photos I can't.
Post Photos
using the same graph above,
result:
"link": "http://www.facebook.com/photo.php?fbid=12234444",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v1/yz/r/StEh3RhPvjk.gif",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/23434352/posts/12143343434"
},
{
"name": "Like",
"link": "http://www.facebook.com/121214334/posts/34343434344"
}
],
"type": "photo",
"object_id": "357309684280810",
I only get this data. There's no picture data that I can get to view post photos.

You can use the Graph API Explorer to experiment with Facebook's API. When you query :
htttps://graph.facebook.com/POST_ID you should get back all the information from that post.

Related

Can't get categories on Likes on new FB graph API (2.5)

I am using this URL to access facebook likes off of an authorized and logged in user:
https://graph.facebook.com/v2.3/me/likes?access_token=accessToken
it returns this
"data": [
{
"name": "Page Name",
"category": "Category name",
"id": "12345678",
"created_time": "2012-03-26T08:02:01+0000"
},
However on my new app which uses API 2.5
https://graph.facebook.com/v2.5/me/likes?access_token=accessToken
it returns this
"data": [
{
"name": "Page Name",
"id": "12345678",
"created_time": "2012-03-26T08:02:01+0000"
},
Which is minus the category name.
I have my new app registered in FB and it will not allow me change API from 2.5, and even on my new app if I use the 2.3 URL it will still not display categories.
Does anyone know what extra calls I need to make to get categories or why they have disapeared in newer versions of the API, I can't find anything on google or on FB's doco's
It´s called "Declarative Fields", check out the changelog for v2.4: https://developers.facebook.com/docs/apps/changelog#v2_4
That´s what you need to change:
/me/likes?fields=name,category&access_token=accessToken

Can I aggregate Facebook Likes, Tweets, and Google Pluses?

I'm building a voting application on my new website, cabinethardware.org. I'd like the voting to be done in such a way that when someone votes for a project (to receive a $1000 rebuilding grant) that they are encouraged to plug the project via social networks. My programmer has had difficulty with the application, and it occurred to me that one way of doing it is to just put like, tweet and G+ buttons on the site and add them together. So if a project gets 24 likes, 12 tweets, and 18 G+, it would have 64 votes. It doesn't bother me if someone votes on all three engines.
Before a project is eligible for a grant, it must receive 100 votes. My question is, is there a way that I can aggregate the likes, tweets, and G+ so that I can see on the backend how many votes each project has, without going to each project and adding them up by hand? Also, I'd like to display to customers the combined total.
Does anyone know of a way to combine the count of these three?
For Google+, you would only need to perform one API call to the Google+ APIs that would be searching the Google+ public data. Searching the Google+ public data is demonstrated in the API explorer.
The post response contains information about reshares and +1s:
"verb": "post",
"object": {
"objectType": "note",
"content": "Setting up a server-side flow project that accesses Google+ data using the .NET stack can be a little tricky, I walk you through it in this blog post.",
"url": "https://plus.google.com/109716647623830091721/posts/g8LjdGAXdDc",
"replies": {
"totalItems": 0,
"selfLink": "https://www.googleapis.com/plus/v1/activities/z125srm50lf1slxrd04cfftatqyoglnoqio/comments"
},
"plusoners": {
"totalItems": 6,
"selfLink": "https://www.googleapis.com/plus/v1/activities/z125srm50lf1slxrd04cfftatqyoglnoqio/people/plusoners"
},
"resharers": {
"totalItems": 0,
"selfLink": "https://www.googleapis.com/plus/v1/activities/z125srm50lf1slxrd04cfftatqyoglnoqio/people/resharers"
},
For Facebook, you can use the Pages API to count likes for your page, you can experiment with this in their API explorer.
The following data shows their response data:
{
"about": "Build and distribute amazing social apps on Facebook. https://developers.facebook.com/ ",
"company_overview": "Facebook Platform enables anyone to build social apps on Facebook, mobile, and the web.\n\n",
"is_published": true,
"talking_about_count": 39241,
"username": "FacebookDevelopers",
"website": "http://developers.facebook.com",
"were_here_count": 0,
"category": "Product/service",
"id": "19292868552",
"name": "Facebook Developers",
"link": "https://www.facebook.com/FacebookDevelopers",
"likes": 952596,
"cover": {
"cover_id": "10151121467948553",
"source": "https://fbcdn-sphotos-f-a.akamaihd.net/hphotos-ak-ash4/s720x720/299374_10151121467948553_45631061_n.png",
"offset_y": 0
}
}
Likes are just a member in the response data.
For twitter, you can query for mentions of a user with their search API and passing a search string for the user as #user. A count of the objects within results is going to be your mention count. The response data is a little too much to paste in here but here's an example query using their API.

facebook user profiles by likes

I have a "Like"-object data from facebook:
{
"name": "24",
"category": "Tv show",
"id": "14176232250",
"created_time": "2010-10-29T17:46:27+0000"
}
it's possible to get all users, which have that "object" in their "likes"?
It is not possible to retrieve information on users who like a page via either the Graph API or FQL.
See this previous question: Retrieve Facebook Fan Names

Scope of Facebook API

I am trying to learn and create a Facebook API on the go. However, I haven't found any page on the developer pages that specifies the scope of the Facebook API in great detail. I understand public information can be accessed using Graph API. But at the same time understand that further access is possible, not sure how much though.
Is there anyway to access the 'Edit news feed options' of a user that authorizes an application?
I don't really understand what you mean by "scope", but the Graph API is not more than a series of URLs to contact the facebook servers with queries and obtain answers in form of JSON objects.
You can start learning by looking at the reference for the API here:
http://developers.facebook.com/docs/reference/api/
There are unofficial APIs for every language you can imagine, for example java: http://code.google.com/p/facebook-java-api/ , c#: http://facebooksdk.codeplex.com/ , etc.
To read the news feed, you can access it by:
https://graph.facebook.com/me/home?access_token=TOKEN (where TOKEN is the access token)
Fb will respond with a JSON object similar to the one pasted below.
{
"data": [
{
"id": "11111_1111111111,
"from": {
"name": "Name",
"id": "11111111"
},
"message": "SOME_MESSAGE",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/111111/posts/11111"
},
{
"name": "Like",
"link": "http://www.facebook.com/11111/posts/11111"
}
],
"type": "status",
"created_time": "2011-04-20T20:19:04+0000",
"updated_time": "2011-04-20T20:19:04+0000"
},
etc etc etc
],
"paging": {
"previous": "https://graph.facebook.com/me/home?access_token=TOKEN",
"next": "https://graph.facebook.com/me/home?access_token=TOKEN"
}
}
Having that, you can use the ID for the person or the message to perform new queries, as explained in the FB API page:
All of the objects in the Facebook
social graph are connected to each
other via relationships. Bret Taylor
is a fan of the Coca-Cola page, and
Bret Taylor and Arjun Banker are
friends. We call those relationships
connections in our API. You can
examine the connections between
objects using the URL structure
https://graph.facebook.com/ID/CONNECTION_TYPE.
The connections supported for people
and pages include:
Almost every information on FB is accessible through the Graph API, provided the user authorized the app with the rigth permissions:
http://developers.facebook.com/docs/authentication/permissions/

How to access Facebook Fan Page Photos within external Website

We are trying to utilize the facebook photo hosting and allow our visitors to view photos via our webpage that have been uploaded to our fan wall.
Does anyone know how this can be achieved?
Thank in advance!
Steven.
Using the social graph, you can do this, provided the script has an access token for your facebook page app ID or your photo permissions are set to be completely public.
Using the social graph, you basically access the photos via a REST like web service. The webservice call will return a JSON object of dataExample:
https://graph.facebook.com/cocacola/albums
(Photo albums for the Coca Cola fan page)
So the first step would be to retrieve the albums using a URL like the one above.
Traverse through the photo albums and get the object ID of the album you want.
{
"id": "455377148305",
"from": {
"name": "Coca-Cola",
"category": "Company",
"id": "40796308305"
},
"name": "Coca-Cola Fanmeile FIFA WM 2010",
"link": "http://www.facebook.com/album.php?aid=249745&id=40796308305",
"count": 20,
"type": "normal",
"created_time": "2010-10-22T15:53:36+0000",
"updated_time": "2010-10-22T15:55:23+0000",
"comments": {}
},
Once you have the object ID, you can access it by simply placing it as the first paramter of the graph URL. E.g:
https://graph.facebook.com/40796308305
From there, you should be able to grab the actual URL to the images (depending on permission settings)
{
"id": "40796308305",
"name": "Coca-Cola",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs236.ash2/50516_40796308305_7651_s.jpg",
"link": "http://www.facebook.com/coca-cola",
"category": "Company",
"website": "http://www.coca-cola.com",
"username": "coca-cola",
"products": "Coca-Cola is the most popular and biggest-selling soft drink in history, as well as the best-known product in the world.\n\nCreated in Atlanta, Georgia, by Dr. John S. Pemberton, Coca-Cola was first offered as a fountain beverage by mixing Coca-Cola syrup with carbonated water. Coca-Cola was introduced in 1886, 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.",
"likes": 22264613
}