|
|
@@ -17,11 +17,19 @@ import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
|
|
+import org.springframework.util.ResourceUtils;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.net.ssl.SSLContext;
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.FileReader;
|
|
|
+import java.io.IOException;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URL;
|
|
|
+import java.net.URLDecoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Paths;
|
|
|
import java.security.cert.X509Certificate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
@@ -30,6 +38,7 @@ import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Locale;
|
|
|
import java.util.UUID;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
public class CspUtil {
|
|
|
private final static String username = "njzm01";
|
|
|
@@ -38,9 +47,9 @@ public class CspUtil {
|
|
|
private final static String serverRoot = "https://api.5gcsp.mas.10086.cn/ocsp/developer";
|
|
|
private final static String fileServerRoot = "https://api.5gcsp.mas.10086.cn/ocsp/fileservice";
|
|
|
|
|
|
- private final static String CONTENT_TYPE_TEXT = "text/plain";
|
|
|
- private final static String CONTENT_TYPE_FILE = "application/vnd.gsma.rcs-ft-http+xml";
|
|
|
- private final static String CONTENT_TYPE_CARD = "application/vnd.gsma.botmessage.v1.0+json";
|
|
|
+ private final static String CONTENT_TYPE_TEXT = "text/plain";
|
|
|
+ private final static String CONTENT_TYPE_FILE = "application/vnd.gsma.rcs-ft-http+xml";
|
|
|
+ private final static String CONTENT_TYPE_CARD = "application/vnd.gsma.botmessage.v1.0+json";
|
|
|
private final static String CONTENT_TYPE_MULTI = "multipart/mixed; boundary=\"[next]\"";
|
|
|
|
|
|
private static RestTemplate restTemplate;
|
|
|
@@ -195,85 +204,11 @@ public class CspUtil {
|
|
|
OutboundMessageRequest request = new OutboundMessageRequest();
|
|
|
request.setDestinationAddress(Arrays.asList(tel));
|
|
|
request.setContentType(CONTENT_TYPE_MULTI);
|
|
|
- String body = "--next\r\n" +
|
|
|
- "Content-Type: application/vnd.gsma.botmessage.v1.0+json\r\n" +
|
|
|
- "Content-Disposition: inline; filename=\"Message\"\r\n" +
|
|
|
- "Content-Length: 902\r\n" +
|
|
|
- "\r\n" +
|
|
|
- "{\r\n" +
|
|
|
- " \"message\": {\r\n" +
|
|
|
- " \"generalPurposeCard\": {\r\n" +
|
|
|
- " \"layout\": {\r\n" +
|
|
|
- " \"cardOrientation\": \"VERTICAL\"\r\n" +
|
|
|
- " },\r\n" +
|
|
|
- " \"content\": {\r\n" +
|
|
|
- " \"media\": {\r\n" +
|
|
|
- " \"mediaUrl\": \"https://cdn.server/path/media.mp4\",\r\n" +
|
|
|
- " \"mediaContentType\": \"video/mp4\",\r\n" +
|
|
|
- " \"mediaFileSize\": 2718288, \r\n" +
|
|
|
- " \"thumbnailUrl\": \"https://cdn.server/path/media.png\",\r\n" +
|
|
|
- " \"thumbnailContentType\": \"image/png\",\r\n" +
|
|
|
- " \"thumbnailFileSize\": 3141,\r\n" +
|
|
|
- " \"height\": \"MEDIUM_HEIGHT\"\r\n" +
|
|
|
- " },\r\n" +
|
|
|
- " \"title\": \"This is a single rich card.\",\r\n" +
|
|
|
- " \"description\": \"This is the description of the rich card. It's the first field that will be truncated if it exceeds the maximum width or height of a card.\"\r\n" +
|
|
|
- " }\r\n" +
|
|
|
- " }\r\n" +
|
|
|
- " }\r\n" +
|
|
|
- "}\r\n" +
|
|
|
- "--next\r\n" +
|
|
|
- "Content-Type: application/vnd.gsma.botsuggestion.v1.0+json\r\n" +
|
|
|
- "Content-Disposition: inline; filename=\"Chiplist.lst\"\r\n" +
|
|
|
- "Content-Length: 550\r\n" +
|
|
|
- "\r\n" +
|
|
|
- "{\r\n" +
|
|
|
- " \"suggestions\": [\r\n" +
|
|
|
- " {\r\n" +
|
|
|
- " \"reply\": {\r\n" +
|
|
|
- " \"displayText\": \"Yes\",\r\n" +
|
|
|
- " \"postback\": {\r\n" +
|
|
|
- " \"data\": \"set_by_chatbot_reply_yes\"\r\n" +
|
|
|
- " }\r\n" +
|
|
|
- " }\r\n" +
|
|
|
- " },\r\n" +
|
|
|
- " {\r\n" +
|
|
|
- " \"reply\": {\r\n" +
|
|
|
- " \"displayText\": \"No\",\r\n" +
|
|
|
- " \"postback\": {\r\n" +
|
|
|
- " \"data\": \"set_by_chatbot_reply_no\"\r\n" +
|
|
|
- " }\r\n" +
|
|
|
- " }\r\n" +
|
|
|
- " },\r\n" +
|
|
|
- " {\r\n" +
|
|
|
- " \"action\": {\r\n" +
|
|
|
- " \"urlAction\": {\r\n" +
|
|
|
- " \"openUrl\": {\r\n" +
|
|
|
- " \"url\": \"https://www.google.com\"\r\n" +
|
|
|
- " }\r\n" +
|
|
|
- " },\r\n" +
|
|
|
- " \"displayText\": \"Open website or deep link\",\r\n" +
|
|
|
- " \"postback\": {\r\n" +
|
|
|
- " \"data\": \"set_by_chatbot_open_url\"\r\n" +
|
|
|
- " }\r\n" +
|
|
|
- " }\r\n" +
|
|
|
- " },\r\n" +
|
|
|
- " {\r\n" +
|
|
|
- " \"action\": {\r\n" +
|
|
|
- " \"dialerAction\": {\r\n" +
|
|
|
- " \"dialPhoneNumber\": {\r\n" +
|
|
|
- " \"phoneNumber\": \"+1650253000\"\r\n" +
|
|
|
- " }\r\n" +
|
|
|
- " },\r\n" +
|
|
|
- " \"displayText\": \"Call a phone number\",\r\n" +
|
|
|
- " \"postback\": {\r\n" +
|
|
|
- " \"data\": \"set_by_chatbot_open_dialer\"\r\n" +
|
|
|
- " }\r\n" +
|
|
|
- " }\r\n" +
|
|
|
- " }\r\n" +
|
|
|
- " ]\r\n" +
|
|
|
- "}\r\n" +
|
|
|
- "--next--\r\n";
|
|
|
+
|
|
|
+
|
|
|
+ String body = Files.lines(Paths.get(URLDecoder
|
|
|
+ .decode(CspUtil.class.getClassLoader().getResource("卡片悬浮.txt").getPath())))
|
|
|
+ .collect(Collectors.joining("\r\n"));
|
|
|
|
|
|
System.out.println(body);
|
|
|
|