DwApiBase
Base class providing common properties and methods.
The following exceptions can be thrown by all functions.
DwApiException EX_CONFIGURATION curl and allow_url_fopen disabled.
DwApiException EX_INVALID_ARRAY Invalid parameter, array expected.
DwApiException EX_INVALID_BOOL Invalid parameter, bool expected.
DwApiException EX_INVALID_STRING Invalid parameter, non-empty string expected.
DwApiException EX_CURL curl failed.
DwApiException EX_FOPEN file_get_contents failed.
DwApiException EX_DANIWEB Invalid request or no data.
Only EX_CURL
, EX_FOPEN
and EX_DANIWEB
are to be expected on a live environment. EX_CURL
or EX_FOPEN
can occur
when communication fails. EX_DANIWEB
means the request was rejected by the DaniWeb API, due to invalid parameters
(e.g. invalid access token). The other exceptions should only occur when developing as they are either programmatic,
or configuration issues.
Returns an alphabetically sorted list of supported article types, to be used as a filter in some methods.
Parameters
None
Return value
Array
Without access token:
- code
- interviews
- news
- reviews
- solved
- threads
- tutorials
- unanswered
- whitepapers
With access token, additionally:
- recommended
- viewed
- watching
Returns an alphabetically sorted list of supported post types, to be used as a filter in some methods.
Parameters
None
Return value
Array
- downvoted
- solved
- upvoted
Returns an alphabetically sorted list of supported relation types, to be used as a filter in some methods.
Parameters
None
Return value
Array
- ancestors
- children
- descendants
Returns an alphabetically sorted list of RSS article types, to be used as a filter in DwApiRss->GetFeed.
Parameters
None
Return value
Array
- code
- interviews
- news
- reviews
- solved
- threads
- tutorials
- unanswered
- whitepapers
Returns an alphabetically sorted list of supported sort types, to be used as a filter in some methods.
Parameters
None
Return value
Array
- firstpost
- lastpost
include 'DwApiBase.class.php';
$dwApi = new DwApiBase();
try
{
$articleTypes = $dwApi->GetArticleTypes();
$postTypes = $dwApi->GetPostTypes();
$relationTypes = $dwApi->GetRelationTypes();
$rssArticleTypes = $dwApi->GetRssArticleTypes();
$sortTypes = $dwApi->GetSortTypes();
}
catch (DwApiException $exception)
{
die($exception->getMessage());
}