Facebook rankings and kpi for specific pages - facebook

I would like to make an application or even a page in my localhost to do what fanpage karma facebook rankings does.
I don't want the facebook insights because I want to have kpi,graphs/charts,rankings and/or insights for the pages i want, just like the fanpagekarma does.

Most of this information can be obtained via
graph.facebook.com/PAGE_ID which will give for example graph.facebook.com/cocacola
{
"id": "40796308305",
"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.",
"app_id": "0",
"can_post": false,
"category": "Food/beverages",
"checkins": 146,
"cover": {
"cover_id": "10152297032458306",
"source": "http://sphotos-f.ak.fbcdn.net/hphotos-ak-prn1/s720x720/625442_10152297032458306_574021701_n.jpg",
"offset_y": 0,
"offset_x": 0
},
"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.\n\nCoca-Cola Page House Rules: http://CokeURL.com/q28a",
"founded": "1886",
"has_added_app": false,
"is_community_page": false,
"is_published": true,
"likes": 64355037,
"link": "https://www.facebook.com/coca-cola",
"name": "Coca-Cola",
"talking_about_count": 1485039,
"username": "coca-cola",
"website": "http://www.coca-cola.com",
"were_here_count": 0
}
In the KPI Overview this takes care of
Fans
Talking about
Then when a user logins into fanpagekarma, the call to graph.facebook.com/page_id/posts can be used to get
Posts per day
Response rate
Engagement
Post Interaction
Post History
The rest of the detailed analytics is just some number crunching on the data from /page_id/posts

Related

How to get social media links from Google Knowledge

Currently I'm working on a project that require me to collect celebrities followers number (from instagram or facebook).
To get that number, i have to get
1. celebrities instagram link
2. celebrities facebook link
3. send a request to instagram or facebook API to get their followers number
I have been researching for google knowledge API for celebrities instagram and facebook link. but what I get from it isn't satisfying.
For example, I put a request on google Knowledge,
https://kgsearch.googleapis.com/v1/entities:search?query=Ariana+Grande&limit=1&indent=1&key={API-CODE}
and the result is
{"#context": {
"#vocab": "schema.org/",
"goog": "schema.googleapis.com/",
"EntitySearchResult": "goog:EntitySearchResult",
"detailedDescription": "goog:detailedDescription",
"resultScore": "goog:resultScore",
"kg": "g.co/kg"
},
"#type": "ItemList",
"itemListElement": [
{
"#type": "EntitySearchResult",
"result": {
"#id": "kg:/m/09gkdy4",
"name": "Ariana Grande",
"#type": [
"Thing",
"Person"
],
"description": "Singer",
"image": {
"contentUrl": "t0.gstatic.com/images?q=tbn:ANd9GcS3KH3ae6ChLCPLguyQXbLbEXDTNMZ1Sb2LsMx6Vr-pjeuHg5AZ",
"url": "da.wikipedia.org/wiki/Ariana_Grande",
"license": "creativecommons.org/licenses/by/2.0"
},
"detailedDescription": {
"articleBody": "Ariana Grande-Butera, known professionally as Ariana Grande, is an American singer and actress. She began her career in the Broadway musical 13, before landing the role of Cat Valentine on the Nickelodeon television series Victorious in 2009. ",
"url": "en.wikipedia.org/wiki/Ariana_Grande",
"license": "en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"
},
"url": "www.arianagrande.com"
},
"resultScore": 802.862244
}
]
}
There's no information regarding her instagram or facebook link from the result, but if we search manually on google, it shows her instagram and facebook link on search result.
My question are:
1. Any way to get those link from Google knowledge?
2. Or any easier way to get follower number from celebrities beside my way? (jugling from 2-3 different APIs)
Thanks.
I really appreciate any comment and help.
You can use wikidata.org. There are steps:
Search https://www.wikidata.org/w/api.php?action=wbsearchentities&search=Ariana+Grande&language=en&format=json
{"searchinfo":{"search":"Ariana Grande"},"search":[{"id":"Q151892","concepturi":"http://www.wikidata.org/entity/Q151892","url":"//www.wikidata.org/wiki/Q151892","title":"Q151892","pageid":153289,"label":"Ariana Grande","description":"American actress, singer, composer and dancer","match":{"type":"label","language":"en","text":"Ariana Grande"}}],"success":1}
Get id Q151892 from the response and get the entity https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q151892&format=json&props=claims
There is a big response. You need the value arianagrande of claim P2003 from a list of claims. It refers to Instagram username (P2013 for Facebook)
Get public info from https://www.instagram.com/arianagrande/?__a=1
user:
follows:
count
followed_by:
count
media:
count

Display Facebook likes without button

I'm trying to display the number of likes I have on Facebook but without their ugly button. Is there a way to just get the number of likes without any images so that I can apply css to just the number and display it on my main webpage?
There Developer page doesn't seem to be any help that I can find.
Thanks!
Make a http request to the graph API:
https://graph.facebook.com/{your-page-name-or-id}
It will return a json object containing information of this page. You can test it on your browser. An example:
https://graph.facebook.com/cocacola
returns:
{
"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": 45669549,
"cover": {
"cover_id": "10151829640053306",
"source": "http://a8.sphotos.ak.fbcdn.net/hphotos-ak-ash3/s720x720/529413_10151829640053306_446360541_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.",
"checkins": 106,
"talking_about_count": 671246
}
It also works for profiles (the information returned is different), apps, and any facebook object!
This only returns public information. If you want to retrieve private information (maybe pictures or posts) you need to get an OAuth token and pass it to the Graph API
If you need more info, check OAuth and Open Graph API on the developers help. (https://developers.facebook.com/docs/opengraph/tutorial/)
$pageContent = file_get_contents('http://graph.facebook.com/YOURPAGENAMEHERE');
$parsedJson = json_decode($pageContent);
$likes = $parsedJson->likes;
echo $likes;
I have this one running myself. Keep in mind that you do this with a cronjob and store it in your database because it is quite slow.

How to correctly redirect to the facebook page tab URL after authorization

I have changed the way my facebook page tab app asks for permissions.
I was using the javascript approach with FB Dialog and now I am using the redirect approach (in which the user is redirected to a FB page where the permissions are asked and then is redirected back to the facebook page tab).
The reason of the change is that I believe this approach will present
less bugs and issues than using the javascript dialogs.
When using the redirect approach, I need to specify the URL that the user will be redirected after providing permissions. I would like that this url was the url of the facebook page tab with the app installed.
When building the url of redirect, I know the current page_id and my app_id. With these info, I need to build the facebook page tab url, which should look like this:
https://www.facebook.com/pages/PAGE-SLUG/{#APP_ID}?sk=app_{#APP_ID}
The problem is that I don't know what is the PAGE-SLUG. The tests I have run with the url above (using the PAGE-SLUG as anything) end up redirecting to the correct URL. However, knowing that Facebook is a very unstable platform, I would like to know it there is any better approach to building this redirect url.
EDIT: the above approach has a problem. The redirect loses the SSL protocol and uses the HTTP link when the facebook user doesn't use SSL by default.
It's very simple actually, you can call the Graph API with PHP like so:
$facebook->api("/{PAGE_ID}");
// change {PAGE_ID} to the page id you are redirecting back to
the return value is a json array with "link" in it -> that's the URL you are looking for :-)
Example Return:
{
"id": "XXXXXXXXX",
"name": "My Demo Page",
"picture": "",
"link": "https://www.facebook.com/pages/My-Demo-Page/XXXXXXXXX",
"likes": 123456,
"category": "Product/service",
"can_post": true,
"type": "page"
}
You can also query by the page name, if you know it, for example:
querying the Graph API with:
$facebook->api("/coca-cola");
Will result in:
{
"id": "40796308305",
"name": "Coca-Cola",
"picture": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/174560_40796308305_2093137831_s.jpg",
"link": "https://www.facebook.com/coca-cola",
"likes": 40680159,
"cover": {
"cover_id": "10150682306963306",
"source": "https://fbcdn-sphotos-a.akamaihd.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": -33.816989983333,
"longitude": 150.84844081667
},
"can_post": true,
"checkins": 80,
"talking_about_count": 297576,
"type": "page"
}
Edit:
A more clear explanation:
Call the Graph API with the current page id.
If the result is no false, then the redirect_uri would be the link
returned from the call.
Otherwise, the redirect_uri should be yourdomain.com/middle-page.php?page_id=XXX
If the user then accepts the application and the redirect_uri is the middle page,
you then call the Graph API again, but this time, you use the Access Token received
from Facebook. now you should have the real page url and you can add any additional
details you need (like ?sk_app=APP_ID)
According to Facebook own documentation, It's not clear what happens if the user decided not no accept the application. I think the user will redirect back to the redirect_uri, which then you can check if you have "user_id" in the signed_request, but I'm not 100% sure... Creating a simple app demo and checking :-)

How to redirect to a Facebook fanpage with ID of fanpage?

I have the ID of a facebook fanpage, and only the ID. Which link I have to build to redirect to this fanpage?
If you only want link that will bring you to the fanpage itself you may use:
http://facebook.com/ANY_FACEBOOK_ID
It'll work for any Facebook ID, no matter page, user, application
Update:
As discussed in comments to other answer there is a some downsides to the link described above:
This is in no way official way and it's not documented, so it may just stop working without any notice...
Any arguments passed to this link are removed on redirection to Page. (Using http://facebook.com/PAGEID?sk=notes will not redirect to Notes application)
So if you need to direct users not only to the page itself but to application on a Page you may use links like:
http://facebook.com/pages/-/PAGEID?sk=app_APPID
Well as you query the graph using the object id (user, page..group...etc):
https://graph.facebook.com/40796308305
{
"id": "40796308305",
"name": "Coca-Cola",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/157930_40796308305_262497158_s.jpg",
"link": "https://www.facebook.com/coca-cola",
"likes": 40005128,
"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": -33.816989983333,
"longitude": 150.84844081667
},
"can_post": true,
"checkins": 78,
"talking_about_count": 583000
}
Querying Facebook directly would also redirect to the "object" page:
https://www.facebook.com/40796308305 --> https://www.facebook.com/cocacola
https://www.facebook.com/579187142 --> https://www.facebook.com/ifaour
Yet this is not an official way. So I'm not sure if this could stop working in the future.

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
}