Skip to content

Commit ef7a5d8

Browse files
committed
use guzzle
1 parent 879d39d commit ef7a5d8

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
],
1212
"require": {
1313
"php": ">=5.6",
14-
"mobtexting/php-http-client": "1.0"
14+
"guzzlehttp/guzzle": "^7.4@dev"
1515
},
1616
"require-dev": {
1717
"mockery/mockery": "^0.9.5",
@@ -28,4 +28,4 @@
2828
}
2929
},
3030
"minimum-stability": "dev"
31-
}
31+
}

src/Client.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
namespace Mobtexting\Message;
44

5-
use Mobtexting\Http\Client as HttpClient;
5+
use GuzzleHttp\Client as GuzzleHttpClient;
66

77
class Client
88
{
99
protected $username;
1010
protected $password;
1111
protected $client;
1212
protected $endpoint = 'https://portal.mobtexting.com/api/v2/sms/send';
13+
protected $body;
1314

1415
/**
1516
* Mobtexting constructor.
@@ -21,7 +22,7 @@ public function __construct($username, $password = null, $client = null)
2122
{
2223
$this->username = $username;
2324
$this->password = $password;
24-
$this->client = $client ?: new HttpClient($this->endpoint);
25+
$this->client = $client ?: new GuzzleHttpClient();
2526
}
2627

2728
public function send($to, $params = [])
@@ -32,15 +33,29 @@ public function send($to, $params = [])
3233

3334
$params = $this->map($params);
3435

35-
return $this->getClient()->post($params);
36+
$response = $this->getClient()->post(
37+
$this->endpoint, [
38+
'form_params' => $params,
39+
'http_errors' => false,
40+
],
41+
);
42+
43+
$this->body = $response->getBody()->getContents();
44+
45+
return $this;
46+
}
47+
48+
public function json()
49+
{
50+
return $this->body;
3651
}
3752

3853
protected function map($params = [])
3954
{
4055
$mapping = [
4156
'token' => 'access_token',
4257
'text' => 'message',
43-
'to' => 'to',
58+
// 'to' => 'to',
4459
'from' => 'sender',
4560
];
4661

0 commit comments

Comments
 (0)