zoukankan      html  css  js  c++  java
  • 获取AppStore上架后的应用版本号

    应用通过审核以后,由开发者设置应用上架,但何时能在appstore搜索到该应用,这个时间不等,有时候15分钟左右有时候2个多小时,以前就是隔一段时间打开网页然后刷新一下,或者搜索一下,查看版本号,操作几次后明显感觉很崩溃了…

     

    既然只是想知道应用的版本号,只要抓取页面,然后获取页面的版本号信息,就知道是否更新过来了,然后通过公司内部的OA接口,发送一条消息,告知所有相关的人员版本号已经更新了…

     

    我用node.js实现的,代码大约在30行左右,下面是实现…

     

    这里我借助了request这个模块 npm install request (查看模块详情>>)

       1: var request = require('request')
       2: var request = request.defaults({jar: true})
       3:  
       4: function getAppVersion() {
       5:     request.get("http://itunes.apple.com/cn/app/xxx/idxxxx?mt=8&t=" + new Date().getTime(), function(error, response, body) {
       6:         if (/<li><span class="label">版本: </span>([^<]+)</li>/.test(body)) {
       7:             var currVer = RegExp["$1"];
       8:             console.log("当前版本:" + currVer);            
       9:             if (currVer == "1.0.2") {
      10:                 return sendOANotification(currVer);
      11:             }                
      12:         }            
      13:         setTimeout(getAppVersion, 3 * 1000);
      14:     })
      15: }
      16:  
      17: function sendOANotification(currVer) {
      18:     request.post('http://oa.xxx.net/login.php', {form:{UNAME:"meteoric_cry", PASSWORD:"xxxx"}}, function(error, respose, body) {
      19:         if (/location="general";/.test(body)) {
      20:             var uid_str = ["meteoric"].join(",");//需要添加多个人,只需要在数组里添加uid
      21:             var url = "http://oa.xxx.net/general/reservation/sendsmsapi.php?uid='"+uid_str+"'&cont='AppStore Version:"+currVer+"'";
      22:  
      23:             request.get(url, function(error, response, body) {
      24:                 //console.log(body)
      25:                 console.log("OA消息发送成功");
      26:             })
      27:         } else {
      28:             console.log("登录OA失败");        
      29:         }
      30:     })
      31: }
      32:  
      33: getAppVersion()

     

    这个功能,如果想灵活一点,就让调用者传入参数:应用的下载地址、最新的版本号、刷新网页的频率、需要通知的人员列表。可以做成一个客户端应用(Exe程序),或者hta程序,或者其它任意不需要依赖其它人安装额外环境的程序

  • 相关阅读:
    简单选择排序就是简单~~~
    快速排序的性能和名字一样优秀
    网关Ocelot功能演示完结,久等了~~~
    打个赌,用得最多的冒泡排序肯定少了个关键点
    C7 : 进程环境
    Java Native Interface Specification
    JNI简易开发
    Java Native Interface Specification
    MultilingualSimpleObject
    Java Native Interface Specification
  • 原文地址:https://www.cnblogs.com/meteoric_cry/p/3291814.html
Copyright © 2011-2022 走看看