Skip to content

Instantly share code, notes, and snippets.

@mppatterson
mppatterson / google-analytics-service-object-php
Created April 2, 2014 14:12
Connecting to Google Analytics via a service object (server-to-server)
// Setup the service object
$client_id = 'xxx.apps.googleusercontent.com';
$service_account_name = 'xxx@developer.gserviceaccount.com';
$client_secret = 'notasecret';
$keyfile = 'path_to_your_key.p12';
$client->setClientSecret($client_secret);
$client->setAssertionCredentials(
new Google_Auth_AssertionCredentials(
// Sample from: https://developers.google.com/analytics/solutions/articles/hello-analytics-api
// Download the API Client on https://github.com/google/google-api-php-client/tree/master/src
// Require 'Google/Client.php' and set your include path to include the src dir, i.e.:
set_include_path(join(":", array(get_include_path(),
YOUR_APP_PATH.'/google-api-php-client/src',
)));
// Setup the service object
@mppatterson
mppatterson / connect-to-analytics
Last active August 29, 2015 13:58
How to Connect to Google Analytics API
Login to the Google account which has access to your analytics
Create an OAuth key on https://console.developers.google.com/
Store the keyfile in your app (and add it to gitignore)
Add your "xxx@developer.gserviceaccount.com" account to Google Analytics as a "Read & Analyze" user
Use the code from https://developers.google.com/analytics/solutions/articles/hello-analytics-api to get started
@mppatterson
mppatterson / install
Created February 21, 2014 20:00
Install Phabricator on Ubuntu
wget http://www.phabricator.com/rsrc/install/install_ubuntu.sh
bash install_ubuntu.sh
sudo vim /etc/apache2/sites-enabled/000-default
################
<VirtualHost *>
# Change this to the domain which points to your host.
ServerName codereview.localhost
@mppatterson
mppatterson / gist:9134550
Created February 21, 2014 13:50
Use Different Ports on Apache
<VirtualHost *:80>
DocumentRoot /home/user/app/
<Directory /home/user/app/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn