https://github.com/moceanapi/mocean-sdk-php7
Mocean SDK
https://github.com/moceanapi/mocean-sdk-php7
Last synced: 6 months ago
JSON representation
Mocean SDK
- Host: GitHub
- URL: https://github.com/moceanapi/mocean-sdk-php7
- Owner: MoceanAPI
- License: mit
- Created: 2021-02-25T09:43:11.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-10-18T07:24:42.000Z (about 3 years ago)
- Last Synced: 2025-03-11T10:43:58.550Z (10 months ago)
- Language: PHP
- Size: 202 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
MoceanAPI Client Library for PHP
============================
[](https://packagist.org/packages/mocean/client7)
[](https://github.com/MoceanAPI/mocean-sdk-php7/actions/workflows/build.yml)
[](https://codecov.io/gh/MoceanAPI/mocean-sdk-php)
[](https://app.codacy.com/project/MoceanAPI/mocean-sdk-php/dashboard)
[](https://github.styleci.io/repos/138724921)
[](https://packagist.org/packages/mocean/client)
[](https://packagist.org/packages/mocean/client)
*This library requires a minimum PHP version of 5.5*
This is the PHP client library for use Mocean's API. To use this, you'll need a Mocean account. Sign up [for free at
moceanapi.com][signup].
* [Installation](#installation)
* [Usage](#usage)
* [Example](#example)
## Installation
To use the client library you'll need to have [created a Mocean account][signup].
To install the PHP client library using Composer.
```bash
composer require mocean/client7
```
## Usage
If you're using composer, make sure the autoloader is included in your project's bootstrap file:
```php
require_once "vendor/autoload.php";
```
Create a client with your API key and secret:
```php
use Mocean\Client;
use Mocean\Client\Credentials\Basic;
$mocean = new Client(new Basic('API_KEY_HERE','API_SECRET_HERE'));
```
## Example
To use [Mocean's SMS API][doc_sms] to send an SMS message, call the `$mocean->message()->send();` method.
The API can be called directly, using a simple array of parameters, the keys match the [parameters of the API][doc_sms].
```php
$res = $mocean->message()->send([
'mocean-to' => '60123456789',
'mocean-from' => 'MOCEAN',
'mocean-text' => 'Hello World'
]);
echo $res;
```
### Responses
For your convenient, the API response data can be accessed either using php `object` style or `array` style
```php
echo $res; //show full response string
echo $res['status']; //show response status, '0' in this case
echo $res->status; //same as above
```
## Documentation
Kindly visit [MoceanApi Docs][doc_main] for more usage
## License
This library is released under the [MIT License][license]
[signup]: https://dashboard.moceanapi.com/register?medium=github&campaign=sdk-php
[doc_main]: https://moceanapi.com/docs/?php
[doc_sms]: https://moceanapi.com/docs/?php#send-sms
[license]: LICENSE