当前位置: 首页 > news >正文

自己怎么做网站一般网站建设流程有哪些步骤

自己怎么做网站,一般网站建设流程有哪些步骤,网站开发初学,房地产 网站模板一、背景说明 在已有的项目中,已经获取到了Graph的AccessToken并保存在内存里面。所以不希望再通过client secret或者certificate去创建GraphServiceClient对象。希望使用现有的token字符串来创建初始化创建GraphServiceClient从而来实现Graph其他API功能。 二、具体…
一、背景说明

在已有的项目中,已经获取到了Graph的AccessToken并保存在内存里面。所以不希望再通过client secret或者certificate去创建GraphServiceClient对象。希望使用现有的token字符串来创建初始化创建GraphServiceClient从而来实现Graph其他API功能。

二、具体实现

2.1 需要Java Graph SDK依赖 加入到pom.xml文件内

 <!-- Microsoft Graph SDK for Java --><dependency><groupId>com.microsoft.graph</groupId><artifactId>microsoft-graph</artifactId><version>[5.0,)</version></dependency><!-- Azure AD Authentication SDK for Java --><dependency><groupId>com.azure</groupId><artifactId>azure-identity</artifactId><version>[1.3,)</version></dependency>

2.2 代码片段

  public static GraphServiceClient initGraphServiceClient() {IAuthenticationProvider authProvider = new IAuthenticationProvider() {@Overridepublic CompletableFuture<String> getAuthorizationTokenAsync(URL requestUrl) {CompletableFuture<String> future = new CompletableFuture<>();future.complete(Your_AccessToken);return future;}};return GraphServiceClient.builder().authenticationProvider(authProvider).buildClient();}
三、测试

下面代码是实现调用创建GraphServiceClient,调用graph api发送带附件的邮件。

	public static String sendMail() {try {String mfrom = "xxxx@outlook.com";String to = "xxxx@outlook.com";GraphServiceClient<Request> graphClient = initGraphServiceClient();Message message = new Message();message.subject = "Meet for lunch?";ItemBody body = new ItemBody();body.contentType = BodyType.TEXT;body.content = "The new cafeteria is open.";message.body = body;LinkedList<Recipient> toRecipientsList = new LinkedList<Recipient>();Recipient toRecipients = new Recipient();EmailAddress emailAddress = new EmailAddress();emailAddress.address = to;toRecipients.emailAddress = emailAddress;toRecipientsList.add(toRecipients);message.toRecipients = toRecipientsList;// 构建附件LinkedList<Attachment> attachmentsList = new LinkedList<Attachment>();FileAttachment attachments = new FileAttachment();attachments.name = "hello word.txt";attachments.oDataType = "#microsoft.graph.fileAttachment";attachments.contentType = "text/plain";attachments.contentBytes = Base64.getDecoder().decode("SGVsbG8gV29ybGQh");attachmentsList.add(attachments);AttachmentCollectionResponse attachmentCollectionResponse = new AttachmentCollectionResponse();attachmentCollectionResponse.value = attachmentsList;AttachmentCollectionPage attachmentCollectionPage = new AttachmentCollectionPage(attachmentCollectionResponse, null);message.attachments = attachmentCollectionPage;// 以指定用户邮箱发送邮件graphClient.users(mfrom).sendMail(UserSendMailParameterSet.newBuilder().withMessage(message).withSaveToSentItems(true).build()).buildRequest().post();log.info("send email success");return "success";} catch (Exception e) {e.printStackTrace();log.error("send email error : {}", e.getMessage());return e.getMessage();}}

http://www.yayakq.cn/news/976289/

相关文章:

  • 高中网站制作私密浏览器下载
  • 洛阳网站建设外包中建集团官网
  • 怎么样在网上建设网站挣钱谷歌搜索引擎首页
  • dede做网站俄罗斯国际空间站
  • 自己怎么开网站好姑娘5免费高清观看
  • 深圳网站排名优化团队wap网站asp源码
  • 深圳网站建设学校东莞工厂网站建设
  • 自己做的网站本地调试软文是什么文章
  • 网站正能量入口软件商城下载安卓版
  • 郑州建设局网站肃宁网站建设公司
  • 做网站搞友情链接商丘网站建设价格
  • 淘宝客网站源码和模版有什么区别wordpress后端
  • 四川网站建设有哪些北京网站建设公司房山华网
  • 刷赞网站推广免费软件查备案网站
  • 网站建设公司电话咨询设计图片logo免费
  • 济南建设网站 概况5 网站建设的基本步骤是
  • 网站开发找工作wordpress安装分享插件下载
  • 基于lamp网站建设实例做医疗器械网站怎么找高清大图
  • 做网站好不好网站建设公司推荐
  • 宁夏做网站找谁上海都有哪些公司
  • 企业网站设计方式有哪些仿站网站建设
  • 网站建设询价报告力天装饰口碑怎么样
  • 网站加速器怎么开quick chat wordpress
  • 网站建设需要工作计划电子商务网站建设实训
  • 住房和城乡建设部网站中国建造师网优秀的图片设计网站
  • 北京网站建设公司内江手机版传奇发布网站
  • 铁岭免费移动网站建设vs2012网站开发环境
  • 长沙门户网站南昌城乡住房建设厅网站
  • 怎么做app网站wordpress翻页图片效果
  • 网站建设免费的服务器阿里云网站空间购买