Skip to content

Commit

Permalink
New implementation based on Guzzle
Browse files Browse the repository at this point in the history
  • Loading branch information
Synchro committed Jun 9, 2015
1 parent 87d0cdb commit cabd32a
Show file tree
Hide file tree
Showing 8 changed files with 538 additions and 269 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
testsettings.php
test.php
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ This contains a PHP client library and example code for the [smartmessages.net](

Please feel free to suggest modifications, submit tickets and pull requests in [our github repo](https://github.com/Smartmessages/PHPClient) - these libraries are intended to make YOUR life easier!

You can load this class via composer:
You can (and should) add this to your project using composer:

```
composer require smartmessages/phpclient
composer require smartmessages/phpclient=~2.0
```

Version 2.0 was rewritten to use [Guzzle](http://docs.guzzlephp.org/en/latest/) as its HTTP client, providing faster, more robust processing and [PSR-7](http://www.php-fig.org/psr/psr-7/) compatibility with many frameworks.

To install the library and its dependencies, run `composer install`, then load the autoloader with `require 'vendor/autoload.php';`.

Complete documentation for the API can be found in [our help wiki](https://wiki.smartmessages.net/#API)

See the accompanying LICENSE file for terms of use (MIT).
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"name": "smartmessages/phpclient",
"description": "Client wrapper for the Smartmessages.net web API",
"require": {
"php": ">=5.3.0",
"ext-openssl": "*"
"php": ">=5.4.0",
"ext-openssl": "*",
"guzzlehttp/guzzle": "~6.0"
},
"license": "MIT",
"authors": [
Expand All @@ -12,7 +13,7 @@
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"minimum-stability": "stable",
"autoload": {
"psr-4": {
"Smartmessages\\": "src/"
Expand Down
241 changes: 241 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions example-full.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
* or in response to the getLists API call
*/
$testlistid = 0;

//You can set the above properties in this included file in order not to pollute this example code with real data!
if (file_exists('testsettings.php')) {
include 'testsettings.php';
Expand Down
10 changes: 5 additions & 5 deletions example-simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/**
* A simple example of connecting to the Smartmessages API and calling a function.
*/
//Load the class, or use composer's autoloader
require 'src/Smartmessages/Client.php';
//Load composer's autoloader
require 'vendor/autoload.php';

//See testsettings-dist.php
if (file_exists('testsettings.php')) {
Expand All @@ -15,8 +15,8 @@
//Login
$sm->login($user, $pass, $apikey, $baseurl);
$tl = $sm->getTestList();
//Log out
$sm->logout();
$p = $sm->ping();
//Log out happens automatically
} catch (Smartmessages\Exception $e) {
echo "<h1>Exception caught</h1>\n<p>An error (" . $e->getCode() . ') occurred: ' . $e->getMessage() . "</p>\n";
echo "#Exception caught:\nAn error (", $e->getCode(), ') occurred: ', $e->getMessage(), "\n";
}
Loading

0 comments on commit cabd32a

Please sign in to comment.