Skip to content
This repository has been archived by the owner on Jun 19, 2018. It is now read-only.

Commit

Permalink
PHP doesnt consider ; numeric so we would previously fail when a vect…
Browse files Browse the repository at this point in the history
…orized list of IDs was attempted + added inital README
  • Loading branch information
Thomas McDonald committed Jun 26, 2010
1 parent 1125e37 commit a37244e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 90 deletions.
12 changes: 12 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
##PHPstack

PHPstack is an easy to use wrapper for the Stack Exchange API.

<?php
require_once('lib/requestcore.class.php');
require_once('phpstack.class.php');

$so = new PHPstack('stackoverflow.com', 'yourAPIKey');
$answer = $so->getAnswers(2921234));
print_r($answer);
?>
90 changes: 0 additions & 90 deletions phpstack.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ function setUseragent($ua) {
*/
function getAnswers($id, $opt = NULL) {
if (!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The answer ID must be numeric", E_USER_ERROR);
}

return $this->request('answers/' . $id, $opt);
}

Expand Down Expand Up @@ -143,11 +138,6 @@ function getAnswers($id, $opt = NULL) {
*/
function getAnswerComments($id, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The answer ID must be numeric");
}

return $this->request('answers/' . $id . '/comments', $opt);
}

Expand Down Expand Up @@ -192,10 +182,6 @@ function getAllBadges() {
function getBadges($id, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The badge ID must be numeric", E_USER_ERROR);
}

return $this->request('badges/' . $id, $opt);
}

Expand Down Expand Up @@ -244,10 +230,6 @@ function getTagBadges() {
function getComments($id, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The comment ID must be numeric", E_USER_ERROR);
}

return $this->request('comments/' . $id, $opt);
}

Expand All @@ -268,10 +250,6 @@ function getComments($id, $opt = NULL) {
function getError($id) {
$opt = array();

if(!is_numeric($id)) {
trigger_error("The error ID must be numeric", E_USER_ERROR);
}

return $this->request('errors/' . $id, $opt);
}

Expand Down Expand Up @@ -311,40 +289,24 @@ function getQuestionsSummary($opt = NULL) {
function getQuestions($id, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The question ID must be numeric", E_USER_ERROR);
}

return $this->request('questions/' . $id, $opt);
}

function getQuestionAnswers($id, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The question ID must be numeric", E_USER_ERROR);
}

return $this->request('questions/' . $id . '/answers', $opt);
}

function getQuestionComments($id, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The question ID must be numeric", E_USER_ERROR);
}

return $this->request('questions/' . $id . '/comments', $opt);
}

function getQuestionTimeline($id, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The question ID must be numeric", E_USER_ERROR);
}

return $this->request('questions/' . $id . '/timeline', $opt);
}

Expand All @@ -363,20 +325,12 @@ function getQuestionsUnanswered($opt = NULL) {
function getRevisions($id, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The question ID must be numeric", E_USER_ERROR);
}

return $this->request('revisions/' . $id, $opt);
}

function getRevision($id, $guid, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The question ID must be numeric", E_USER_ERROR);
}

return $this->request('revisions/' . $id . '/' . $guid, $opt);
}

Expand All @@ -401,110 +355,66 @@ function getUsersSummary($opt = NULL) {
function getUsers($id, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The user ID must be numeric", E_USER_ERROR);
}

return $this->request('users/' . $id, $opt);
}

function getUsersAnswers($id, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The user ID must be numeric", E_USER_ERROR);
}

return $this->request('users/' . $id . '/answers', $opt);
}

function getUsersBadges($id, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The user ID must be numeric", E_USER_ERROR);
}

return $this->request('users/' . $id . '/badges', $opt);
}

function getUsersComments($id, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The user ID must be numeric", E_USER_ERROR);
}

return $this->request('users/' . $id . '/comments', $opt);
}

function getUsersCommentsTo($id, $toid, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The user ID must be numeric", E_USER_ERROR);
}

return $this->request('users/' . $id . '/commnets/' . $toid, $opt);
}

function getUsersFavourites($id, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The user ID must be numeric", E_USER_ERROR);
}

return $this->request('users/' . $id . '/favourites', $opt);
}

function getUsersMentions($id, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The user ID must be numeric", E_USER_ERROR);
}

return $this->request('users/' . $id . '/mentioned', $opt);
}

function getUsersQuestions($id, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The user ID must be numeric", E_USER_ERROR);
}

return $this->request('users/' . $id . '/questions', $opt);
}

function getUsersReputation($id, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The user ID must be numeric", E_USER_ERROR);
}

return $this->request('users/' . $id . '/reputation', $opt);
}

function getUsersTags($id, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The user ID must be numeric", E_USER_ERROR);
}

return $this->request('users/' . $id . '/tags', $opt);
}

function getUsersTimeline($id, $opt = NULL) {
if(!$opt) $opt = array();

if(!is_numeric($id)) {
trigger_error("The user ID must be numeric", E_USER_ERROR);
}

return $this->request('users/' . $id . '/tags', $opt);
}

Expand Down

0 comments on commit a37244e

Please sign in to comment.