Skip to main content
9 of 19
edited title
Jeff Atwood
  • 960
  • 1
  • 12
  • 18

stack.PHP - Clean, Easy to Use Wrapper for PHP

http://files.quickmediasolutions.com/stackphp_big.png

##Code Snippet


Simple example demonstrating usage:

<?php

// Bring in the files
require '../StackExchange/StackBase.php';
require '../StackExchange/PostExchange.php';

// Connect to serverfault, with no key, caching results for 10 minutes
$posts = new PostExchange('stackoverflow', NULL, 10);

// Poll for 5 unanswered questions
$unanswered_questions = $posts->Unanswered(array('pagesize' => 5, 'body' => true));

foreach($unanswered_questions as $q)
{
    echo $q->title . " by " . $q->owner->display_name . "\n";
    echo substr(strip_tags($q->body), 0, 100) . "...\n";
    echo "Tags: " . implode(", ", $q->tags) . "\n";
    // This was silly. They're all "unanswered".
    //echo "Answers: " . count($q->answers) . "\n";
    echo "--------------\n";
}

?>

##About

stack.PHP is a clean and easy to use wrapper for the StackOverflow API. It has no dependencies and has a very small filesize. It exposes the complete list of API methods (including the StackAuth methods) to PHP applications. It is also thoroughly documented.

stack.PHP powers StackMobile.com, StackImage, StackMail, and portions of Column 80 so you can be assured that it is both reliable and stable.

###License

stack.PHP is available under the MIT License

###Download

I have released version 0.3 and it can be downloaded from:

http://launchpad.net/stackphp/0.3/stackphp0.3/+download/stackphp_0.3.tar.gz

Older versions:

http://launchpad.net/stackphp/0.2/stackphp0.2/+download/stackphp_0.2.tar.gz
http://launchpad.net/stackphp/0.1/stackphp0.1/+download/stackphp_0.1.tar.gz

###Platform

PHP 5.2 or higher.

##Contact

I can be reached at [email protected]

##Code

The code can be retrieved from http://launchpad.net/stackphp

Contributions to stack.PHP are always welcome.
Contact me on LaunchPad if you are interested.

Nathan Osman
  • 23.3k
  • 11
  • 61
  • 107