i don’t have a step-by-step guide for you, but it is fairly easy to implement the oauth library for your needs. below a quick overview, hope it helps. After altering the library you can just create a model for each oauth application (ie. a twitter model, facebook model etc.). I’m currently developing a twitter app, i’ll share my full functional model and oauth implementation as soon as it’s finished.
OAuth Implementation Overview:
—-
* Download the oauth-php library from code.google.com (see link above) and extract package
* Create /path/to/ci/install/system/application/libraries/OAuthClient.php and ./OAuth/
* OAuthClient.php is just an empty with require statements:
<?php
require_once(dirname(__FILE__).'/OAuth/OAuthStore.php');
require_once(dirname(__FILE__).'/OAuth/OAuthRequester.php');
class OAuthClient {
}
* Copy contents of oauth-php/library/ to your newly created OAuth dir in the ci-libraries directory
—————
Now comes the tricky part, pay attention!
OAuth-php uses different methods for storing the tokens/key’s/etc. The class files can be found at /system/application/libraries/OAuth/store/. For this example I’ll use the session method (the easiest one the change), but it is the same for the other store methods.
Ok let’s go! Open up OAuth/store/OAuthStoreSession.php
First add a new private var to store the CI super object;
class OAuthStoreSession extends OAuthStoreAbstract
{
private $session;
private $ci;
...
Next uncomment the if clause starting the session, get a superobject instance en load the session library (if not already loaded):
public function __construct( $options = array() )
{
/**
if (!session_id()) {
session_start();
}
*/
$this->ci =& get_instance();
$this->ci->load->library('session');
...
Now simply change every occurence of fetching or setting a session variable ($_SESSION[’...’]) with the CI code, but pay attention! The $_SESSION variable is passed by reference, so we also need to set the session variable at the end of the constructor:
...
$this->ci->session->set_userdata(
array('oauth_'.$options['consumer_key'] => $this->session)
);
...
Now also change the file /system/application/libraries/OAuth/session/OAuthSessionSESSION.php and you’re done! Load the oauth library and use as you would normally:
$this->load->library('OAuthClient'); // make available the lib
$options = array();
$oauth_store = OAuthStore::instance('Session', $options);
$request = new OAuthRequester($request_uri, 'GET/POST', $params);
$result = doRequest(0);