Exemple #1
0
<?php

// project: Curly.php
// author: nsimaria - Nuno Simaria - nsimaria@gmail.com
//
// license: Use at your own will and risk. It would be nice of you to credit the author of the code, but hey, no pressure. Some feedback would be awesome as well.
//
// description: Curly.php is a simple curl wrapper for curl requests on PHP. It is not intended to be a complete, fully featured wrapper. Its a light weight class to quickly try API Requests.
//
// SiMA - Software is Modern Art
require_once 'Curly.php';
// requests http://api.twitter.com/users/_nsimaria_.json and returns the json string
$curly = new Curly();
$curly->home('http://api.twitter.com/');
$curly->action('users/_nsimaria_');
$curly->format('json');
$curly->request();
// requests http://your.api.home.com/statuses/home_timeline.xml?count=5 with basic authentication
// non-working example!
$curly = new Curly();
$curly->home('http://your.api.home/');
$curly->login('username', 'password');
$curly->action('statuses/home_timeline');
$curly->format('xml');
$curly->data('count', 5);
$curly->request('post');
// asking for the info on how it went:
$curly->info();