CakePHP-Copula / Linkedin

LinkedIn API support for Cakephp.
16 stars 9 forks source link

Installation

Step 1: Download / clone the following plugins:

Step 2: Setup your database.php

var $linkedin = array(
    'datasource' => 'Linkedin.Linkedin',
    'login' => '<linkedin api key>',
    'password' => '<linkedin api secret>',
);

Step 3: Install the Apis-OAuth Component for authentication

MyController extends AppController {
    var $components = array(
        'Apis.Oauth' => 'linkedin',
    );

    function connect() {
        $this->Oauth->connect();
    }

    function linkedin_callback() {
        $this->Oauth->callback();
    }
}

Step 4: Use the datasource normally

Look inside the Config map for a list of endpoints or add more yourself! The 'fields' key optionally lets you specify what fields you want returned. Here is a list for reference

Class MyModel extends AppModel {

    function readProfile() {
        $this->setDataSource('linkedin');
        $data = $this->find('all', array(
            'path' => 'people/~',
            'fields' => array(
                'first-name', 'last-name', 'summary', 'specialties', 'associations', 'honors', 'interests', 'twitter-accounts', 
                'positions' => array('title', 'summary', 'start-date', 'end-date', 'is-current', 'company'), 
                'educations', 
                'certifications',
                'skills' => array('id', 'skill', 'proficiency', 'years'), 
                'recommendations-received',
            ),
        ));
        $this->setDataSource('default');
    }
}

You can also pass search parameters to certain endpoints:

$data = $this->find('all', array(
    'path' => 'people-search',
    'conditions' => array(
        'count' => 500,
        'firstName' => 'bob',
        'lastName' => 'dillan',
        'company' => 'columbia records club',
    ),
    'fields' => array(
        'first-name', 'last-name',
        'positions' => array('title', 'company'),
    ),
));