· 7 years ago · Dec 25, 2018, 09:28 AM
1
2 /**
3 * @param string $url
4 * @param array $params
5 * @throws eSMSException
6 * @return array
7 */
8 private function request($url, $params = [])
9 {
10
11 $params['ApiKey'] = $this->api_key;
12 $params['SecretKey'] = $this->secret_key;
13
14 $url .= '?' . http_build_query($params);
15
16 $curl = curl_init($url);
17
18 curl_setopt_array($curl, [
19 CURLOPT_RETURNTRANSFER => true
20 ]);
21
22 $response = json_decode(curl_exec($curl), true);
23
24 curl_close($curl);
25
26 $this->checkResponseError($response);
27
28 return $response;
29 }
30
31 /**
32 * Kiếm tra trạng thái gá»i tin cho từng số má»™t
33 *
34 * @param int $smsId
35 * @return array [
36 * [
37 * 'IsSent' => true,
38 * 'Phone' => 'XXXXX',
39 * 'SendResult' => true
40 * ]
41 * ]
42 *
43 * @throws eSMSException
44 */
45 public function getSendStatusForEachPhoneNumber($smsId)
46 {
47 $url = 'http://rest.esms.vn/MainService.svc/json/GetSmsReceiverStatus_get';
48
49 $params = [
50 'Apikey' => $this->api_key,
51 'Secretkey' => $this->secret_key,
52 'RefId' => $smsId
53 ];
54
55 return $this->request($url, $params);
56 }