Facebook Graph API and
FQL don’t provide you with a simple way of getting the creation date of a Facebook account.
But if you have a valid Facebook Access Token with ‘read_stream’ permission, it is possible to estimate the Facebook account creation date
by finding the creation date of the oldest user post. According to the Facebook documentation,
each query of the stream table is limited to the previous 30 days or 50 posts, whichever is greater, however you can use time-specific fields such as created_time along with FQL operators (such as < or >) to retrieve a much greater range of posts.
Also you must have ‘read_stream’ permission:
Querying without the ‘read_stream’ permission will return only the public view of the data (i.e. data that can be see when the user is logged out).
Here is some code to do that:
Estimate the Facebook account age (AccountAge.php)download
<?php/** * Estimating the Facebook account age by finding the creation date of the oldest post. * A valid Facebook Access Token with read_stream permission is required. * * @author Massoud Seifi, Ph.D. @ MetaDataScience.com */classAccountAge{public$baseUrl;function__construct(){$this->baseUrl='https://graph.facebook.com/';}/** * Run a Facebook FQL query * @param string $fql Facebook query * @param string $access_token Facebook Access Token * @return array Return Facebook query result */publicfunctiondoFQLRequest($fql,$access_token){$url=$this->baseUrl.'fql?q='.urlencode($fql).'&access_token='.$access_token;$ch=curl_init($url);curl_setopt($ch,CURLOPT_TIMEOUT,60);curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);$decodedResult=json_decode(curl_exec($ch),true);curl_close($ch);$result=array();if(isset($decodedResult['data']))$result=$decodedResult['data'];elsethrownewException("Facebook FQL Error. Please check if the access token is valid.\n");return$result;}/** * Estimate the account age by finding the creation date of the oldest post * @param string $access_token Facebook Access Token * @return integer Return the Facebook account age in seconds */publicfunctiongetAccountAge($access_token){$date=new\DateTime('now');$timestamp=$date->getTimestamp();echo"# Finding the oldest post may take several minutes to complete.\n";echo"# Please wait ";while(true){// Loop until finding the oldest postecho".";$fql="SELECT created_time FROM stream WHERE source_id = me()"." AND created_time < ".$timestamp." ORDER BY created_time ASC LIMIT 5000";$result=$this->doFQLRequest($fql,$access_token);if(!isset($result[0]['created_time']))break;$timestamp=$result[0]['created_time'];}echo"\n";$age=$date->getTimestamp()-$timestamp;return$age;}/** * Display the account age in a human readable format * @param int $age Account age in seconds */publicfunctionprintAccountAge($age){$years=floor($age/(365*24*60*60));$months=floor(($age-$years*365*24*60*60)/(30*24*60*60));$days=floor(($age-$years*365*24*60*60-$months*30*24*60*60)/(24*60*60));echo"\nAccount age: $years years, $months months, $days days\n";}}$p=newAccountAge();// You need an Access Token with a read_stream permission$access_token='AAACEdEose0cBAOY7bB3A9m7s3U6hbuJvfECxuZBFRN6YjqPC2eZB5x8WrnK51Gl3WsdwYovmxdPZCKFyJKB5TuFhpxsDJpAZCe9y6eutyQZDZD';$age=$p->getAccountAge($access_token);$p->printAccountAge($age);
Octopress is a “blogging framework for hackers” according to its author, “Brandon Mathis”.
It is built in Ruby and based on the static web-site generator
Jekyll which powers GitHub Pages.
I tried setting up Octopress (on GitHub) by following various tutorials I found online.
Not all of them worked properly.
So, now that I got it working, this tutorial details what worked for me;
and how I was able to get Octopress working on GitHub.
Install Octopress
Here you can find instructions on how to install Octopress on Ubuntu (I currently use version 12.10):
Run ruby --version to be sure is Ruby 1.9.3 installed properly.
Note that these instructions are a bit different from those given in
Octopress Documentation:
I changed .bash_profile to .bashrc and 1.9.3-p0 to 1.9.3-p194 to make it work.
It has a very easy signup process. Be creative to choose a cool username (My username is accesstoken. Is it cool?!). It would be good for your reputation if you can use the same username everywhere, e.g. on Twitter (You can follow me on Twitter with the same username: http://twitter.com/accesstoken).
Create a GitHub repository for the blog
Create a new GitHub repository and name the repository with your user name: [your-username].github.com
Generate a SSH key
Create a SSH key and add it to your GitHub account using the instructions here.
Deploy
Now, run the following command:
1
rake setup_github_pages
It will ask you to enter the read/write url for your repository.
Enter the SSH read/write url for your repository which should be like git@github.com:username/username.github.com.git.
Now, you should have two branches, source and master on your GitHub repository.
The source branch contains the files that are used to generate the blog and the master contains the blog itself.
After a few minutes, you should be able to see the default Octopress page here: http://[your-username].github.com/. Hooray!
Start blogging
Configure your blog
You can find a simple guide here for configuring your Octopress blog.
Create a new post
1
rake 'new_post[Title]'
This will tell you the name of the Markdown file for your new posting. Just open the file and start typing.
1234567891011
---
layout: post
title: "Blogging With Octopress"
date: 2013-02-18 13:18
comments: true
categories: Tutorials
description: "A tutorial for how to use Octopress for blogging."
keywords: "octopress, tutorial for octopress, blogging with octopress"
---
<h1>Hello World!</h1>This is a link to <ahref='http://octopress.org/'>Octopress</a>.
You can use Markdown syntax.
Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).
12
# Hello World!
This is a link to [Octopress](http://octopress.org/).
Now, run the command below to generate posts and pages into the public directory.
1
rake generate
If you want to see a preview of your blog before publishing it to the server, run the command below.
1
rake preview
You will see a message like this:
>>> Compass is polling for changes. Press Ctrl-C to Stop.
Keep it listening (don’t press Ctrl-C), open your browser and open http://localhost:4000 to preview your post.
When you are happy with your new post, you can publish it to the server.
1
rake deploy
Create a new Page
If you want to create, for example, the “about” page for your blog, you need to run the command below.
1
rake new_page["about"]
This will create a new file at source/about/index.markdown that you can edit to write about yourself.
Running rake generate command will generate public/about/index.html from the index.markdown
and rake deploy will push changes to the server.
You can add an “About” link in the navigation bar for this page.
Simply, edit the file source/_includes/custom/navigation.html and add
1
<li><ahref="/about">About</a></li>
Generate and deploy can be done in a single command:
1
rake gen_deploy
Enable comments
Create a disqus account and add your disqus short name in _config.yml to enable comments on your blog.
Done!
Mapping your custom domain to your GitHub pages
Here you can find instructions on how to map your custom domain to your blog:
Register your domain
I registered my domain metadatascience.com at GoDaddy.com but you can use any domain name registrar.
Configure the DNS
Go to DNS Manager on the control panel of your domain. Point your host to 204.232.175.78.
Map your domain to your GitHub pages
I used the commands below to map my domain metadatascience.com to my GitHub pages at accesstoken.github.com.
Replace metadatascience.com with your domain name and accesstoken with your username on GitHub in the code below.