Skip to content

hiwepy/tencentapi-spring-boot-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tencentapi-spring-boot-starter

组件简介

使用说明

1、Spring Boot 项目添加 Maven 依赖
<dependency>
	<groupId>com.github.hiwepy</groupId>
	<artifactId>tencentapi-spring-boot-starter</artifactId>
	<version>${project.version}</version>
</dependency>
2、在application.yml文件中增加如下配置
#################################################################################################
### 腾讯IM、SMS、Live配置:
#################################################################################################
tencent:
  tim:
    sdkappid: 222 
    identifier: 
    expire: 1111
    private-key: sss
3、使用示例

腾讯云短信(Short Message Service,SMS)

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.tencentcloud.spring.boot.sms.TencentSmsTemplate;
import com.tencentcloudapi.sms.v20190711.models.SendSmsResponse;

@SpringBootApplication
public class TencentSmsApplication_Test {
	
	@Autowired
	private TencentSmsTemplate template;
	@Autowired
	private ObjectMapper objectMapper;
	
	@PostConstruct
	public void testSendSms() {

		try {
			SendSmsResponse response = template.send("13733339999", "9781232", "你好");
			System.out.println(objectMapper.writeValueAsString(response));
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
	
	public static void main(String[] args) throws Exception {
		SpringApplication.run(TencentSmsApplication_Test.class, args);
	}

}

即时通信 IM

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.tencentcloud.spring.boot.tim.TencentTimTemplate;
import com.tencentcloud.spring.boot.tim.resp.AccountKickResponse;

@SpringBootApplication
public class TencentTimApplication_Test {
	
	@Autowired
	private TencentTimTemplate template;
	@Autowired
	private ObjectMapper objectMapper;
	
	@PostConstruct
	public void testKick() {

		try {

			AccountKickResponse response =  template.opsForAccount().kick("");
			System.out.println(objectMapper.writeValueAsString(response));
			
			template.opsForAccount().delete(new String[] {"111"});
			template.opsForProfile().portraitGet("111");
			
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
	
	public static void main(String[] args) throws Exception {
		SpringApplication.run(TencentTimApplication_Test.class, args);
	}

}

Jeebiz 技术社区

Jeebiz 技术社区 微信公共号小程序,欢迎关注反馈意见和一起交流,关注公众号回复「Jeebiz」拉你入群。

公共号 小程序

About

tencentapi-spring-boot-starter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages