张延森 hace 3 años
padre
commit
d535e281f3
Se han modificado 2 ficheros con 23 adiciones y 1 borrados
  1. 15
    0
      .vscode/launch.json
  2. 8
    1
      sms.go

+ 15
- 0
.vscode/launch.json Ver fichero

1
+{
2
+  // Use IntelliSense to learn about possible attributes.
3
+  // Hover to view descriptions of existing attributes.
4
+  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+  "version": "0.2.0",
6
+  "configurations": [
7
+    {
8
+      "name": "Launch Package",
9
+      "type": "go",
10
+      "request": "launch",
11
+      "mode": "auto",
12
+      "program": "${fileDirname}"
13
+    }
14
+  ]
15
+}

+ 8
- 1
sms.go Ver fichero

2
 
2
 
3
 import (
3
 import (
4
 	"encoding/json"
4
 	"encoding/json"
5
+	"fmt"
5
 
6
 
6
 	openapi "github.com/alibabacloud-go/darabonba-openapi/client"
7
 	openapi "github.com/alibabacloud-go/darabonba-openapi/client"
7
 	dysmsapi20170525 "github.com/alibabacloud-go/dysmsapi-20170525/v2/client"
8
 	dysmsapi20170525 "github.com/alibabacloud-go/dysmsapi-20170525/v2/client"
40
 		return err
41
 		return err
41
 	}
42
 	}
42
 
43
 
43
-	if _, err := client.SendSms(sendSmsRequest); err != nil {
44
+	result, err := client.SendSms(sendSmsRequest)
45
+	if err != nil {
46
+		print(result)
44
 		return err
47
 		return err
45
 	}
48
 	}
46
 
49
 
50
+	if *result.Body.Code != "OK" {
51
+		return fmt.Errorf("[%s]: %s", *result.Body.Code, *result.Body.Message)
52
+	}
53
+
47
 	return nil
54
 	return nil
48
 }
55
 }