Is there any way to link Facebook Graph data with other data sources (Freebase, DBPedia)? - facebook

I have a set of Interest and Likes data from Facebook that I'm interested in enriching with data from other sources, namely Freebase. Is there some way to identify which entry within Freebase cooresponds to a given entry within the Facebook Graph?
Firstly, Facebook Graph does not offer any links to external sources, so it seems any sort of relationship needs to be found within the external source. I've found that, at least for some entries, Freebase offers a 'Facebook URL' and thus in a roundabout way you can link the two. For example for the band 'Taking Back Sunday', here is the Facebook Graph URL:
https://graph.facebook.com/23854511408
... which alternatively can use the vanity URL:
https://graph.facebook.com/TakingBackSunday
now in Freebase if I view the Taking Back Sunday entry in RDF format (http://rdf.freebase.com/rdf/en.taking_back_sunday) or JSON format I can see a link to the Facebook vanity URL. Assuming this attribute is queryable by MQL then linking Freebase to Facebook Graph via this method is possible. However the problem is that many entries in Freebase do not have a link to Facebook.
Any ideas on if there's a consistent way to discover these connections?

Create a spreadsheet out of your list of Interests and Likes with a column for the name and FB graph URI.
Load the spreadsheet into Google Refine.
Reconcile the name column with Freebase.
Create a new column for the Freebase URI based on your reconciled name column using the following GREL code:
"http://rdf.freebase.com/ns/" + cell.recon.match.id[1,-1].replace("/", ".")
Export your augmented data to a new spreadsheet.

If you can get the Facebook graph data into RDF format and if you're interested in connecting particular kinds of entities (e.g., bands) across the datasets, then you can use a link discovery tool like Silk. You write a mapping that tells Silk how to compares the name, genre, hometown etc., and Silk will calculate the connections. This requires quite a bit of effort though.
Another option might be to use Google Refine, which has a “reconciliation” feature that can discover Freebase entities that match your data. The challenge is again how to get the Facebook data into Google Refine.

Related

Facebook URL Graph Search - Page Queries

I am looking to generate a list of URLS or FB ID's for a set of existing Facebook Pages. Ultimately the initial query I am looking to run is simple: Find all NEW facebook pages created in City XYZ.
The term NEW, is open to interpretation. It could mean "Created this month" Or newer relative others in a set (these details are not important at the moment) . Also, "Pages" refers to fan pages (not user profiles).
I have identified 3 possible approaches. Both of which I am hoping to get some input on. Regarding feasibility and process.
Option 1) Somehow leverage Facebook's Graph API and develop some time of web application to generate a list of all Pages, then filter by city, then filter by date created.
Option 2 (Best Case)) Write or generate a custom Graph Search URL with embedded search criteria and leverage FBs existing search feature to get results. A great example of this approach is used by the tool searchisback.com. Only this tool is used to do advanced searches on People, but I need advanced searches on Pages.
Option 3) Locate a tool that already does this that I can use.
I again hoping to get some input and possible some direction/recommendations.
I should also mention that I actually know very little about Facebook APIs and Facebook Development. My position right now is of some who knows what they want to do, but no idea how to do it.
Option 1: Not possible, you can only search for Pages by name, the Graph Search is not available with the API. Those are all the options: https://developers.facebook.com/docs/graph-api/using-graph-api#search
Option 2: See answer to option 1.
Option 3: There are tools that list Pages, but they all have to add them manually. So there is not really a tool that does what you want to achieve.
In short: What you want to do is not possible.

Google Analytics API, filter by parameter

Our app uses the Google Analytics Rest API. We'd like to get the number of page views generated by different links to the site.
For example, one link to our site might be:
http://oursite.com?linknum=12345
and another might be:
http://oursite.com?linknum=23456
We'd like to track the number of page views by all visitors who click on each link, so we need a way to filter by parameter.
So far, we just get the number of page views for all visitors without any filters:
curl 'https://www.googleapis.com/analytics/v3/data/ga?ids=ga:(our id) &metrics=ga:pageviews&start-date=2014-4-26&end-date=2011-12-08&access_token=(our access token)'
The best way to learn the API is to use the query explorer at
http://ga-dev-tools.appspot.com/explorer/
For your analysis, add dimension=ga:pagePath and sort=ga:pageviews.
In addition, you could ask for pages which match a filter expression.
For example filter=ga:pagePath=#linknum to only include pages with linknum.

How to access links provided on one's timeline?

I would like to have access to the links one shared on their timeline.
Using the API Graph Explorer, I see there is a way to access "links". However, it returns empty data. I believe that this might have been used when posting links in FB was done in a special way, different than posting "usual" status.
Then, I thought, I should probably get all the stream and filter the data for links. But at that point, I'm a little confused:
There are THREE different actions that seem to provide the very same data:
- https://graph.facebook.com/me/feed
- .../me/posts
- .../me/statuses
Are they actually all the same?
In addition, all seem to provide me information that is not up to date, but is true for some point in the near past. Moreover, I would like to know how I can get the relevant data from the beginning of the FB usage, or at least, for a given period of time.
Do an HTTP Get to me/links to get the most recent links the user has shared.
To limit it to a timeframe, you can do me/links?since=YYY&until=ZZZ.
Or you can use the paging object to get the previous and next url to use to get that other page of data.

Facebook Graph API SEO Comments and Profanity Filter

I'm trying to integrate the Facebook comments left on our site in a way in which the content can be crawled by search engines and also for people (although I highly doubt there will be many) who don't have Javascript enabled on their browser.
Currently our Facebook comments are displayed via the use of the Facebook comment social plugin (using the <fb:comments href="MY_URL" num_posts="50" width="665"></fb:comments> tag). This ends up rendering an iFrame (which are mostly ignored by search engine crawlers) so the plan is to render this information and format it with basic HTML. To do this, the comments are pulled using the Graph API - this is then only be displayed to crawlers and people with Javascript disabled.
This all works nicely using the Graph API call (https://graph.facebook.com/comments/?ids=MY_URL), parsing the JSON result and displaying it on the page. The problem is that the <fb:comments> approach filters our results based on a blacklist we have set up on one of our Facebook Apps. The AppId with the relevant blacklist is stored on the page using metadata (<meta property="fb:app_id" content="APP_ID"/>) which the <fb:comments> control obviously must somehow use to filter the comments.
The problem is the Graph API method does not filter any results as I guess no blacklist (or App Id containing a blacklist) is specified. Does anyone know how to specify a Facebook App ID to the API call URL or of another way to not fetch commnents back that violate the terms of the blacklist?
On a side note, I know the debate about filtering content in comments rages on but it is a management decision to implement the blacklist, and one that I have no influence in changing - just incase anyone felt the need to explain the reasons why content filtering is or isn't a good idea!
Any thoughts on a solution?
Unfortunately there's no way to access a filtered list of comments using the API - it might be a reasonably request to have this in the API - you should file a wishlist item in Facebook's bug tracker
Otherwise, the only solution I can think of is to implement your own filter on your side when retrieving and displaying the comments from the API.
According to the Comments plugin documentation the filter on Facebook's side is implemented as a simple substring match, so it should be trivial to implement.
A fairly simple regular expression match should be able to check each comment against a relatively long list quickly.
(Unfortunately, the tradeoff here is that implementing a filter is easy, but you'd also need to write an interface so that whoever's updating the list of disallowed words can maintain the list for both the Facebook plugin, and your own filtering.)
Quote from docs:
The comment is checked via substring matching. This means if you blacklist the
word 'at', if the comment contains the sequence 'a' 't' anywhere it will be
marked with limited visibility; e.g. if the comment contained the words 'bat',
'hat', 'attend', etc it would be caught.
Pretty sure there is no current way of doing this from the graph API, the only thing I can suggest is taking the blacklist and build your own filter

Facebook Graph API: Getting the total number of posts

I've been using the Facebook Graph API to display user posts. When I get the initial "page" of posts, the resulting data object has a paging property object with a previous and next URL property. I was hoping to generate navigation links based on this available paging information. However, sometimes these URLs point to an empty set of data, so I obviously don't want to navigate the user to an empty page.
Is there a way to find the total count of objects in a collection so that better navigation can be derived? Is there any way to get smarter paging data?
Update:
Sorry if my post isn't clear. To illustrate, look at the data at https://graph.facebook.com/7901103/posts and its paging property URLs. Then follow those URLs to see the issue: empty pages of data.
Since it pages the datas with date-time base. You can't get the knowledge of whether if there are datas or not before you actually send the request to it. But you can preload the data from previous url to determine is it suitable to dispaly a previous link in your web page.
Why be dependent of Facebook?
Why don't you preload all data for a user and save into a database. Then you fetch the posts from db and show to user. This way you have all the control on how many posts there are and how to manage next and prev.
I was going to try to post this as a comment to your question, but I can't seem to do so...
I know that the Graph API returns JSON, and while I've never come across a way to have the total number of posts returned, depending on what technology you are using to process the response, you might be able to capture the size of the JSON array containing the posts.
For example, if I were using a java application I could use the libraries available at json.org (or Google GSON, or XStream with the JSON driver) to populate an object and then simply use the JSONArray.length() method to check for the number of posts returned.
see:
http://www.json.org/javadoc/org/json/JSONArray.html
It might seem like a bit of a simplistic solution, but might be the type of work around you require if you can't find a way to have Facebook return that data.
Can you specify what technology your application is based in?