A simple php wrapper for the Designer News API.
- PHP 5.3.x or higher
- cURL
- A valid Designer News Access Token
This library assumes that you have already acquired a valid Access Token using your preferred oAuth library.
Please note that as of this writing, the Designer News API only supports ClientCredentials and Password Grant Types.
You can either download the latest version from the repo, or alternatively install it as a dependency with Composer.
{
"require": {
"ghosh/designernews-php-api": "~1.0"
}
}
Then run composer.phar install
from your command line in your application root folder.
$config = array(
"accessToken" => "YOUR_ACCESS_TOKEN"
);
try
{
$DN = new DesignerNews($config);
}
catch (Exception $e)
{
echo $e->getMessage();
}
This creates a new instance of the Designer News API class and assigns it to the $DN
handle. Its recommended to wrap this in a try
/catch
block to handle any errors that may arise.
accessToken
Required - This is the access token which would be provided to you by your oauth libraryapiVersionSegment
Optional - The current api version. Will default tov1
userAgent
Optional - The user agent for the application. Designer News recommends setting it to your email address so that you can be contacted if any misuse of data is detected. Defaults todesigner-news-api-php-wrapper
The wrapper includes convenient methods used to perform HTTP requests on behalf of the authenticated user. Below you will find a list of all available methods.
$DN->me();
$DN->getStory($id);
$DN->upvoteStory($id);
$DN->commentOnStory($id, $comment);
$DN->getTopStories();
$DN->getRecentStories();
$DN->searchForStory($queryString);
$DN->getComment($id);
$DN->upvoteComment($id);
$DN->replyToComment($id, $reply);
$DN->getMOTD();
$DN->upvoteMOTD();
$DN->downvoteMOTD();
All responses from the Designer News API PHP Wrapper are returned as PHP objects.
Feel free to open a new issue here on github for any bug you may have come across or a feature which you would like added. Pull requests are most welcomed.
release
- Initial Public Releasefeature
- Added Packagist support
release
- Public Beta Release