1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the overtrue/easy-sms. |
5
|
|
|
* |
6
|
|
|
* (c) overtrue <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the MIT license that is bundled |
9
|
|
|
* with this source code in the file LICENSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Overtrue\EasySms\Gateways; |
13
|
|
|
|
14
|
|
|
use Overtrue\EasySms\Contracts\MessageInterface; |
15
|
|
|
use Overtrue\EasySms\Contracts\PhoneNumberInterface; |
16
|
|
|
use Overtrue\EasySms\Support\Config; |
17
|
|
|
use Overtrue\EasySms\Traits\HasHttpRequest; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class MwGateway. |
21
|
|
|
* |
22
|
|
|
* @see hhttp://con.monyun.cn:9960/developer_Center/index.html?htmlURL1=API&htmlURL2=APIone&iden=1334141369429928360 |
23
|
|
|
*/ |
24
|
|
|
class MwGateway extends Gateway |
25
|
|
|
{ |
26
|
|
|
use HasHttpRequest; |
27
|
|
|
|
28
|
|
|
const ENDPOINT_TEMPLATE = 'http://61.145.229.28:8806/MWGate/wmgw.asmx/MongateSendSubmit'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param \Overtrue\EasySms\Contracts\PhoneNumberInterface $to |
32
|
|
|
* @param \Overtrue\EasySms\Contracts\MessageInterface $message |
33
|
|
|
* @param \Overtrue\EasySms\Support\Config $config |
34
|
|
|
* |
35
|
|
|
* @return array |
36
|
|
|
*/ |
37
|
1 |
|
public function send(PhoneNumberInterface $to, MessageInterface $message, Config $config) |
38
|
|
|
{ |
39
|
|
|
$params = [ |
40
|
1 |
|
'query' => ['userId' => $config->get('userId'), |
41
|
1 |
|
'password' => $config->get('password'), |
42
|
1 |
|
'pszMobis' => $to->getUniversalNumber(), |
43
|
1 |
|
'pszMsg' => $message->getContent($this), |
44
|
1 |
|
'iMobiCount' => 1, |
45
|
1 |
|
'pszSubPort' => $config->get('pszSubPort'), |
46
|
1 |
|
], |
47
|
1 |
|
]; |
48
|
1 |
|
$result = $this->request('get', self::ENDPOINT_TEMPLATE, $params); |
49
|
1 |
|
$temp = []; |
50
|
1 |
|
if (isset($result['code'])) { |
51
|
1 |
|
return $result; |
52
|
|
|
} |
53
|
|
|
if (abs(intval($result[0])) > 100000) { |
54
|
|
|
$temp['code'] = 1; |
55
|
|
|
$temp['msg'] = 'success'; |
56
|
|
|
} else { |
57
|
|
|
$temp['code'] = -1; |
58
|
|
|
$temp['msg'] = 'error'; |
59
|
|
|
} |
60
|
|
|
$temp['real_code'] = $result[0]; |
61
|
|
|
|
62
|
|
|
return $temp; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|