欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

MyApps平台4.4版本如何调用第三方接口

程序员文章站 2022-03-10 13:27:06
...
#include "Basis";
  #include "MethodLibrary";
(function () {
     var URLConnector = new Packages.cn.myapps.util.http.HttpRequestUtil();
     var doc = getCurrentDocument();
     var DigestUtils = new Packages.org.apache.commons.codec.digest.DigestUtils();
     var timestamp = Math.round(new Date() / 1000);
     var appld = APPLICATION;
     var domain = DOMAINID;
     var database = DATABASENAME;
     var url = doc.getItemValueAsString("url");
     var HostUrl = "http://localhost:8080/obpm/analysis/douyin";
     var JSONString = URLConnector.post(HostUrl, url);
     var code = JSONString.get("code");
   
     println("JSONString--->" + JSONString);
     var formProcess = getFormProcess();
     var Sequence = new Packages.cn.myapps.util.sequence.Sequence();
     
     var ParentProcess = getDocumentProcess();
     var ParentFormProcess = getFormProcess();
     var ParentDoc = ParentFormProcess.doViewByFormName("analysisRecord", appld);
     var newParentDoc = ParentProcess.doNew(ParentDoc, getWebUser(), createParamsTable());
     var uuid = Sequence.getSequence();
     if ("200".equals(code)) {
         var originalLink = JSONString.get("originalLink");
         println("originalLink--->" + originalLink);
         var backgroundMusic = JSONString.get("backgroundMusic");
         println("backgroundMusic--->" + backgroundMusic);
         var videoCreate_Time = JSONString.get("videoCreate_Time");
         println("videoCreate_Time--->" + videoCreate_Time);
         var noWatermarkLink = JSONString.get("noWatermarkLink");
         println("noWatermarkLink--->" + noWatermarkLink);
         var videoDesc = JSONString.get("videoDesc");
         var musicCover = JSON.parse(JSONString.get("musicCover"));
         var author = JSON.parse(JSONString.get("author"));
                println("author--->"+author)
         var unique_id = author.unique_id;
                if("".equals(unique_id)||unique_id==null){
                        unique_id = author.short_id;
                }
         var nickname = author.nickname;
         var signature = author.signature;
         var Cover = musicCover[0];
         println("Cover--->" + Cover);
         newParentDoc.setId(uuid);
         newParentDoc.addStringItem("number", countNext2("Analysis", true, true, true, 4));
         newParentDoc.addStringItem("nickname", nickname);
         newParentDoc.addStringItem("unique_id", unique_id);
         newParentDoc.addStringItem("details", signature);
         newParentDoc.addStringItem("douyingURL", originalLink);
         newParentDoc.addStringItem("noWatermarkLink", noWatermarkLink);
         var Create_Time = new Date(videoCreate_Time*1000);
                println("videoCreate_Time----->"+videoCreate_Time);
                var Create_TimeString = formatDate(Create_Time);
                println("Create_TimeString--->"+Create_TimeString);
         newParentDoc.addStringItem("videoCreate_Time", Create_TimeString);
         newParentDoc.addStringItem("analysisDate", format(getToday(), "yyyy-MM-dd HH:mm:ss"));
         ParentProcess.doCreate(newParentDoc);
  
     }
})()