Stack.PHP
A simple and easy to use PHP library for the Stack Exchange API.
Public Member Functions | List of all members
Site Class Reference

A Stack Exchange site providing an API. More...

Inheritance diagram for Site:

Public Member Functions

 __construct ($site_data)
 Constructor for a Site object. More...
 
 Answers ($id=null)
 Returns a post request object. More...
 
 Badges ($id=null)
 Returns a badge request object. More...
 
 Comments ($id=null)
 Returns a comment request object. More...
 
 Events ($access_token)
 Returns events that have happened on the site within the last 15 minutes. More...
 
 Info ()
 Returns information about the site. More...
 
 Me ($access_token)
 Returns a request for the user that corresponds with the specified access token. More...
 
 Posts ($id=null)
 Returns a post request object. More...
 
 Privileges ()
 Returns a paged response object for retrieving privileges. More...
 
 Questions ($id=null)
 Returns a question request object. More...
 
 Revisions ($id)
 Returns a revision request object. More...
 
 Search ($search_text)
 Returns questions that match the specified search terms. More...
 
 Similar ($title)
 Returns questions that are similar to the current set of questions. More...
 
 SuggestedEdits ()
 Retrieves all of the pending edit suggestions for the site. More...
 
 Tags ($tags=null)
 Returns a tag request object. More...
 
 Users ($id=null)
 Returns a user request object. More...
 
 Data ()
 Returns the data for this site. More...
 
 Name ()
 Returns the friendly name of the site. More...
 
 URL ()
 Returns the URL of the actual site. More...
 
 offsetSet ($offset, $value)
 Do not use this function. It exists to satisy the interface ArrayAccess.
 
 offsetUnset ($key)
 Do not use this function. It exists to satisy the interface ArrayAccess.
 
 offsetExists ($key)
 Determines whether the given key exists. More...
 
 offsetGet ($key)
 Returns the value of the provided key. More...
 

Detailed Description

A Stack Exchange site providing an API.

This class is instantiated by providing either an array item containing site data or a string containing part of the site's domain name.

Constructor & Destructor Documentation

◆ __construct()

Site::__construct (   $site_data)

Constructor for a Site object.

Parameters
$site_dataa string containing part of the domain name or an array item containing site data

Member Function Documentation

◆ Answers()

Site::Answers (   $id = null)

Returns a post request object.

Parameters
$ideither an answer ID or an array of answer IDs
Returns
a PostRequest object

This method is used for retrieving answers from the site. Similar to the Questions() method, you can chain methods to set parameters and call Exec() to issues the request.

◆ Badges()

Site::Badges (   $id = null)

Returns a badge request object.

Parameters
$ideither a badge ID or an array of badge IDs
Returns
a BadgeRequest object

◆ Comments()

Site::Comments (   $id = null)

Returns a comment request object.

Parameters
$ideither a comment ID or an array of comment IDs
Returns
a PagedRequest object

◆ Data()

Site::Data ( )

Returns the data for this site.

Returns
an associative array of site data

Note: if this data has not been retrieved yet, this function will call the Stats() method to retrieve it.

◆ Events()

Site::Events (   $access_token)

Returns events that have happened on the site within the last 15 minutes.

Parameters
$access_tokena valid access token
Returns
an EventRequest object

◆ Info()

Site::Info ( )

Returns information about the site.

Returns
a PagedRequest object

◆ Me()

Site::Me (   $access_token)

Returns a request for the user that corresponds with the specified access token.

Parameters
$access_tokena valid access token
Returns
a UserRequest object

◆ Name()

Site::Name ( )

Returns the friendly name of the site.

Returns
the friendly name of the site

Note: if this data has not been retrieved yet, this function will call the Stats() method to retrieve it.

◆ offsetExists()

Site::offsetExists (   $key)

Determines whether the given key exists.

Parameters
$keythe key to look up
Returns
TRUE if $key exists

◆ offsetGet()

Site::offsetGet (   $key)

Returns the value of the provided key.

Parameters
$keythe key to look up
Returns
the value of $key

◆ Posts()

Site::Posts (   $id = null)

Returns a post request object.

Parameters
$ideither a post ID or an array of post IDs
Returns
a PostRequest object

◆ Privileges()

Site::Privileges ( )

Returns a paged response object for retrieving privileges.

Returns
a PagedRequest object

◆ Questions()

Site::Questions (   $id = null)

Returns a question request object.

Parameters
$ideither a question ID or an array of question IDs
Returns
a QuestionRequest object

This method is used for retrieving questions from the site. Simply chain methods to the return value of this method and then call Exec() to issue the request and receive a response object.

Example: $response = $site->Questions()->SortByVotes()->Min(100)->Exec();

◆ Revisions()

Site::Revisions (   $id)

Returns a revision request object.

Parameters
$ideither a post ID or an array of post IDs
Returns
a PagedRequest object

◆ Search()

Site::Search (   $search_text)

Returns questions that match the specified search terms.

Parameters
$search_texttext to search for in question titles
Returns
a QuestionRequest object

◆ Similar()

Site::Similar (   $title)

Returns questions that are similar to the current set of questions.

Parameters
$titlea title to test for
Returns
a QuestionRequest object

◆ SuggestedEdits()

Site::SuggestedEdits ( )

Retrieves all of the pending edit suggestions for the site.

Returns
a PagedRequest object

◆ Tags()

Site::Tags (   $tags = null)

Returns a tag request object.

Parameters
$tagseither a tag or an array of tags
Returns
a TagRequest object

◆ URL()

Site::URL ( )

Returns the URL of the actual site.

Returns
the URL of the site

Note: if this data has not been retrieved yet, this function will call the Stats() method to retrieve it.

◆ Users()

Site::Users (   $id = null)

Returns a user request object.

Parameters
$ideither a user ID or an array of user IDs
Returns
a UserRequest object

This method is used for retrieving users and data from those users on the site. Other data, such as questions and answers from the user(s) can be retrieved by chaining method calls and then calling Exec() to make the request.

Example: $response = $site->Users(12)->Questions()->Unanswered()->Exec();


The documentation for this class was generated from the following file: