Skip to content

Commit cabd32a

Browse files
committed
New implementation based on Guzzle
1 parent 87d0cdb commit cabd32a

File tree

8 files changed

+538
-269
lines changed

8 files changed

+538
-269
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
testsettings.php
2+
test.php

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ This contains a PHP client library and example code for the [smartmessages.net](
66

77
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!
88

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

1111
```
12-
composer require smartmessages/phpclient
12+
composer require smartmessages/phpclient=~2.0
1313
```
14+
15+
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.
16+
17+
To install the library and its dependencies, run `composer install`, then load the autoloader with `require 'vendor/autoload.php';`.
18+
1419
Complete documentation for the API can be found in [our help wiki](https://wiki.smartmessages.net/#API)
1520

1621
See the accompanying LICENSE file for terms of use (MIT).

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
"name": "smartmessages/phpclient",
33
"description": "Client wrapper for the Smartmessages.net web API",
44
"require": {
5-
"php": ">=5.3.0",
6-
"ext-openssl": "*"
5+
"php": ">=5.4.0",
6+
"ext-openssl": "*",
7+
"guzzlehttp/guzzle": "~6.0"
78
},
89
"license": "MIT",
910
"authors": [
@@ -12,7 +13,7 @@
1213
"email": "[email protected]"
1314
}
1415
],
15-
"minimum-stability": "dev",
16+
"minimum-stability": "stable",
1617
"autoload": {
1718
"psr-4": {
1819
"Smartmessages\\": "src/"

composer.lock

Lines changed: 241 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example-full.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
* or in response to the getLists API call
4343
*/
4444
$testlistid = 0;
45+
4546
//You can set the above properties in this included file in order not to pollute this example code with real data!
4647
if (file_exists('testsettings.php')) {
4748
include 'testsettings.php';

example-simple.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
/**
33
* A simple example of connecting to the Smartmessages API and calling a function.
44
*/
5-
//Load the class, or use composer's autoloader
6-
require 'src/Smartmessages/Client.php';
5+
//Load composer's autoloader
6+
require 'vendor/autoload.php';
77

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

0 commit comments

Comments
 (0)