Permalink
Browse files

Sparkified the repository, added spark.info and removed cURL as it is…

… now a dependency via Sparks.
  • Loading branch information...
1 parent 68a5a56 commit cc3315ee5b4e2a3a0820229b916bc3cbe356692a Phil Sturgeon committed May 7, 2011
@@ -1,24 +1,23 @@
-CodeIgniter-REST Client
-================
+# CodeIgniter-REST Client
CodeIgniter-REST Client is a CodeIgniter library which makes it easy to do use REST services/API's such as Twitter, Facebook and Flickr, wether they are public or hidden behind HTTP Basic/Digest.
-
-Requirements
-------------
+## Requirements
1. PHP 5.1+
-2. CodeIgniter 1.6.x - 2.0-dev
+2. CodeIgniter 2.0.0+
3. cURL
-4. CodeIgniter Curl library: http://github.com/philsturgeon/codeigniter-curl
+4. CodeIgniter Curl library: http://getsparks.org/packages/curl/show
-Usage
------
+## Usage
- $this->load->library('rest', array(
- 'server' => 'http://twitter.com/'
- ));
-
+ // Load the rest client spark
+ $this->load->spark('restclient');
+
+ // Run some setup
+ $this->rest->initialize(array('server' => 'http://twitter.com/'));
+
+ // Pull in an array of tweets
$tweets = $this->rest->get('statuses/user_timeline/'.$username.'.xml');
This is clearly a VERY simple example and more can much more can be done with it. For up-to-date
View
@@ -0,0 +1,4 @@
+<?php
+
+# Load the rest library when the spark is loaded
+$autoload['libraries'] = array('rest');
View
@@ -1,10 +0,0 @@
-<html>
-<head>
- <title>403 Forbidden</title>
-</head>
-<body>
-
-<p>Directory access is forbidden.</p>
-
-</body>
-</html>
View
@@ -1,46 +0,0 @@
-<?php
-class Test extends Controller
-{
- function index()
- {
- $this->load->helper(array('url', 'form'));
-
- $data = array();
-
- if($this->input->post('server'))
- {
- $this->load->library('rest', array(
- 'server' => $this->input->post('server')
- ));
-
- $method = trim($this->input->post('method', TRUE));
- $uri = trim($this->input->post('uri', TRUE));
- $format = trim($this->input->post('format', TRUE));
- $params = $this->input->post('params', TRUE);
-
- $this->rest->format($format);
- $this->rest->api_key('foo');
- $this->rest->language('en-GB, pr');
-
-// parse_str($params, $params);
-//
-// $params['preview_file'] = 'FOO';//file_get_contents('/Users/phil/Desktop/Files/AstralSpica.jpg');
-// $params['preview_file_ext'] = 'jpg';
-//
-// var_dump($params);
-
- if(in_array($method, array('put', 'post', 'get', 'delete')))
- {
- $result = $this->rest->{$method}($uri, $params);
- }
-
- $this->load->view('test_form', array('result' => $result, 'debug' => $this->rest->debug()));
-
- }
-
- else
- {
- $this->load->view('test_form', array('result' => '', 'debug' => ''));
- }
- }
-}
View
@@ -1,51 +0,0 @@
-<?php
-class Twitter extends Controller {
-
- function __construct()
- {
- parent::Controller();
-
- $this->load->library('rest', array(
- 'server' => 'http://twitter.com/'
- ));
-
- }
-
- function show_user($username = '')
- {
- if(!$username)
- {
- show_error('Please enter a user in the title. Eg: '.anchor('twitter/show_users/philsturgeon', 'twitter/show_users/philsturgeon'));
- }
-
-
- $result = $this->rest->get('users/show/'.$username);
-
- foreach( $result as $thing => $value )
- {
- echo '<strong>'.$thing.':</strong> '.$value.'<br/>';
- }
-
- }
-
- function tweets($username = '')
- {
- if(!$username)
- {
- show_error('Please enter a user in the title. Eg: '.anchor('twitter/tweets/philsturgeon', 'twitter/tweets/philsturgeon'));
- }
-
- $this->load->library('rest', array(
- 'server' => 'http://twitter.com/'
- ));
-
- $tweets = $this->rest->get('statuses/user_timeline/'.$username.'.xml');
-
- echo $this->rest->debug();
-
- }
-
-
-}
-
-?>
View
@@ -1,63 +0,0 @@
-<?php
-
-class Welcome extends Controller {
-
- function __construct() {
- parent::Controller();
-
- $this->load->library('rest', array(
- 'server' => 'http://localhost/classes/restserver/index.php/example_api/',
- 'http_auth' => 'digest',
- 'http_user' => 'admin',
- 'http_pass' => '1234'
- ));
-
- $this->load->helper(array('url', 'form'));
-
- }
-
- function index()
- {
- $this->load->view('welcome_message');
- }
-
- function view_user($id = 0)
- {
- $responce = $this->rest->get('user/id/'.$id, array(
- 'name'=>'Some dude', 'email' => 'dudeface.magee@gmail.com'
- ));
-
- echo "<pre>";
- print_r($responce);
- echo "</pre>";
-
- echo $this->rest->debug();
- }
-
- function new_user()
- {
- $responce = $this->rest->put('user/id/25', array(
- 'name'=>'New guy!', 'email' => 'dudeface.magee@gmail.com', 'status' => 'ADDED!')
- );
-
- echo "<pre>";
- print_r($responce);
- echo "</pre>";
-
- echo $this->rest->debug();
- }
-
- function delete_user($id = 0)
- {
- $responce = $this->rest->delete('user/id/23');
-
- echo "<pre>";
- print_r($responce);
- echo "</pre>";
-
- echo $this->rest->debug();
- }
-
-}
-
-?>
Oops, something went wrong.

0 comments on commit cc3315e

Please sign in to comment.