Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/owenvoke/devrant-php
A simple PHP wrapper for utilising the devRant api.
https://github.com/owenvoke/devrant-php
api devrant php-wrapper
Last synced: about 1 month ago
JSON representation
A simple PHP wrapper for utilising the devRant api.
- Host: GitHub
- URL: https://github.com/owenvoke/devrant-php
- Owner: owenvoke
- License: mit
- Created: 2016-11-23T16:52:35.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-06T14:20:55.000Z (about 7 years ago)
- Last Synced: 2024-11-14T07:38:22.828Z (about 2 months ago)
- Topics: api, devrant, php-wrapper
- Language: PHP
- Homepage: https://packagist.org/packages/pxgamer/devrant-php
- Size: 53.7 KB
- Stars: 5
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-devrant - devRant-PHP - A PHP wrapper for the devRant API (Uncategorized / Uncategorized)
README
# devrant-php
[![Build Status](https://travis-ci.org/pxgamer/devrant-php.svg?branch=master)](https://travis-ci.org/pxgamer/devrant-php)
A simple PHP wrapper for utilising the [devRant](https://devrant.com) api.
## Usage
__Include the class:__
- Using Composer`composer require pxgamer/devrant-php`
```php
getRants(); // Get rants
$devRant->getRants($searchterm); // Get rants using a search query
```
Returns false on failure, or:
```php
[
0 => Rant object,
1 => Rant object,
...
]
```### _Getting a single rant by its id_
```php
$devRant = new \pxgamer\devRant\Connection;
$devRant->getRantById(int);
```
Returns false on failure, or a `Rant` object.### _Getting a user by their id_
```php
$devRant = new \pxgamer\devRant\Connection;
$devRant->getUserById(int);
```
Returns:
```php
[
"success" => true,
"profile" => [
"username" => "",
"score" => 0,
"about" => "",
"location" => "",
"created_time" => 1474613872,
"skills" => "",
"github" => "",
"website" => "",
"content" => [
"content" => [
"rants" => [],
"upvoted" => [],
"comments" => [],
"favorites" => []
[,
"counts" => []
],
"avatar" => []
]
]
```### _Search rants_
```php
$devRant = new \pxgamer\devRant\Connection;
$devRant->getRants('string');
```
Returns false on failure, or:
```php
[
0 => Rant object [
"id" => 0,
"text" => "string",
"num_upvotes" => 0,
"num_downvotes" => 0,
"score" => 0,
"created_time" => 0,
"attached_image" => [
"url" => "string",
"width" => 0,
"height" => 0
],
"num_comments" => 0,
"tags" => [
"string"
],
"vote_state" => 0,
"edited" => false,
"user_id" => 0,
"user_username" => "string",
"user_score" => 0,
"user_avatar" => [
"b" => "string"
]
],
1 => Rant object,
...
]
```### _Getting a user's id from their username_
```php
$devRant = new \pxgamer\devRant\Connection;
$devRant->getUserId('username');
```
Returns:
```php
[
"success" => true,
"user_id" => 0
]
```### _Getting signed in_
```php
$devRant = new \pxgamer\devRant\Connection;
$devRant->login('username', 'password');
```
Returns `true` if successful, `false` if not### _Posting a rant_
```php
use \pxgamer\devRant\Rant;$devRant = new \pxgamer\devRant\Connection;
if ($devRant->login('username', 'password')) {
$devRant->rant(new Rant($rant_content, $tags));
}
```
Returns:
```php
[
"success" => true,
"rant_id" => 31131
]
```### _Posting a comment_
```php
$devRant = new \pxgamer\devRant\Connection;
if ($devRant->login('username', 'password')) {
$devRant->comment($rantId, 'Comment Content');
}
```
Returns:
```php
[
"success" => true
]
```### _Getting Collabs_
```php
$devRant = new \pxgamer\devRant\Connection;$collabs = $devRant->collabs();
```
Returns:
```php
[
"success" => true,
"rants" => [
[0] => [
...
]
]
]
```### _Voting on Rants_
```php
$devRant = new \pxgamer\devRant\Connection;
if ($devRant->login('username', 'password')) {
$voteRant = $devRant->voteRant($rantId, $vote);
}
```
Returns:
```php
[
"success" => true,
"rant" => [
[id] => ...,
...
]
]
```### _Voting on Comments_
```php
$devRant = new \pxgamer\devRant\Connection;
if ($devRant->login('username', 'password')) {
$voteRant = $devRant->voteComment($commentId, $vote);
}
```
Returns:
```php
[
"success" => true,
"comment" => [
[id] => ...,
...
]
]
```### _Getting your notifications_
```php
$devRant = new \pxgamer\devRant\Connection;
if ($devRant->login('username', 'password')) {
$notifications = $devRant->notifs();
}
```
Returns:
```php
[
"success" => true,
"data" => {
"items" => [
...
],
"check_time" => 11111,
"username_map" => {
...
}
}
]
```### _Deleting a rant_
*Please note that this will __permanently__ delete the rant from devRant.*
```php
$devRant = new \pxgamer\devRant\Connection;
if ($devRant->login('username', 'password')) {
$devRant->deleteRant($rantId);
}
```
Returns:
```php
[
"success" => true
]
```### _Deleting a comment_
*Please note that this will __permanently__ delete the comment from devRant.*
```php
$devRant = new \pxgamer\devRant\Connection;
if ($devRant->login('username', 'password')) {
$devRant->deleteComment($commentId);
}
```
Returns:
```php
[
"success" => true
]
```### _Deleting your account_
*Please note that this will __permanently__ delete your account from devRant.*
```php
$devRant = new \pxgamer\devRant\Connection;
if ($devRant->login('username', 'password')) {
$devRant->deleteAccount();
}
```
Returns:
```php
[
"success" => true
]
```## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.