Use the Appcan client to automatically update the PHP version (full). appcan version _ PHP Tutorial

Source: Internet
Author: User
Tags file url
Use the Appcan client to automatically update the PHP version (full) and appcan version. Use the Appcan client to automatically update the PHP version number (full). The appcan version number is automatically updated on the app during project development, after reading the relevant information, the Appcan client is automatically updated. the Appcan client is used to automatically update the PHP version (full) and appcan version.

In the process of project development, when the app is automatically updated, check the relevant information and then sort out the Appcan client's automatic PHP version update method. the specific code is described as follows.

Server Files: update. php, version. php, and version. xml

Update. php content:

PHP

<? Phpdefine ('CIN', true); $ oldver =$ _ REQUEST ['Ver ']; // The version passed by the client $ platform =$ _ REQUEST ['platform']; // client platform $ info = simplexml_load_file ('version. xml '); $ iphone_filename = $ info-> news ['iPhone _ filename']; // download the iphone file $ android_filename = $ info-> news ['Android _ filename']; // download the file $ version = $ info-> news ['version'] from androiad; // version if ($ version> $ oldver) {switch ($ platform) {case "0": // iphone echo "<? Xml version = \ "1.0 \" encoding = \ "UTF-8 \"?> "; Echo"
 
  
"; Echo"
  
   
I2ty
  "; // Client name echo"
  
   
ItunesURL
  "; // Echo returned to the client"
  
   
0
  "; // File size echo"
  
   
". $ Version ."
  "; // Echo version information"
 "; Break; case" 1 ": // android echo" <? Xml version = \ "1.0 \" encoding = \ "UTF-8 \"?> "; Echo"
 
  
"; Echo"
  
   
I2ty
  "; // Client name echo"
  
   
Http://i2ty.com/app/ ". $ android_filename ."
  "; // Echo returned to the client"
  
   
0
  "; // File size echo"
  
   
". $ Version ."
  "; // Echo version information"
 "; Break ;}}?>

Version. php content:

PHP

<? Phpdefine ('CIN', true); $ result ['vtitle'] = "update"; $ result ['vcontent'] = "updated in the new version !~ New feature to fix various errors "; print_r (json_encode ($ result);?> Version. xml content: PHP <? Xml version = "1.0" encoding = "UTF-8"?>
  
  
 Index.html client: PHPwindow. uexOnload = function (type) {if (! Type) {update ();} var flag_sdcard = 1; var updateurl = ''; // download the new apk file URL var filepath2 ="/sdcard /"; // save it to the SD card var fileName = ''; // New version file name var platform =''; // platform version function update () {// Android version, show the download progress (step: 7) uexDownloaderMgr. onStatus = function (opId, fileSize, percent, status) {if (status = 0) {// download... log ('Download percent '+ percent +' % '); uexWindow. toast ('1', '5', 'Download' + localStorage. app_title + 'new version, please Later. Progress: '+ percent +' % ', '');} else if (status = 1) {// download complete. uexWindow. closeToast (); uexDownloaderMgr. closeDownloader ('14'); // Close the uexWidget. installApp (filepath2 + fileName); // install and download the apk file} else {uexWindow. toast ('1', '5', 'download error. Please close '+ localStorage. app_title + 'run again. ', '') ;}}; // Android version, creates the download object callback function (step: 6) uexDownloaderMgr. cbCreateDownloader = function (opId, dataType, data) {Log ('uexdownloadermgr. cbCreat EDownloader data = '+ data); if (data = 0) {// updateurl is the uexDownloaderMgr that puts the global variable after calling the cbCheckUpdate callback. download ('14', updateurl, filepath2 + fileName, '0'); // start to download the apk file} else if (data = 1 ){;} else {;}; // prompts the event callback function of the update modal box button to determine whether to choose update or cancel (step: 5) uexWindow. cbConfirm = function (opId, dataType, data) {Log ('uexwindow. cbConfirm '); // The call dialog box prompts the function if (data = 0) {// the user clicks the button later and does not update} else {// the user clicks the OK button to update the function. If (platform = 0) {// Apple update, load the appstore path uexWidget in the browser. loadApp (updateurl, '',''); // uexWidget. loadApp ("", "", updateurl); // The old method is no longer available.} Else if (platform = 1) {// Android version update, download uexDownloaderMgr by creating a download object. createDownloader ("14") ;}else {;}}; // call the callback function to check the update. after the request is successful, the modal box appears, asking the user to select whether to update now (step: 4) uexWidget. cbCheckUpdate = function (opCode, Ype, jsonData) {Log ('jsondata = '+ jsonData); var obj = eval (' + jsonData + ')'); if (obj. result = 0) {// tips = "update address:" + obj. url +"
File name: "+ obj. name +"
File size: "+ // obj. size +"
Version: "+ obj. version; updateurl = obj. url; fileName = obj. name + ". apk "; getVersionContent (); // var value =" later; update "; // var mycars = value. split (";"); // uexWindow. confirm ('', 'has a new version. is it updated? ', Mycars); // The prompt box is displayed, whether to confirm the update} else if (obj. result = 1) {// Apple // alert ("update address:" + obj. url +"
File name: "+ obj. name +"
File size: "+ // obj. size +"
Version: "+ obj. version); // tips = "The current version is the latest"; alert (tips);} else if (obj. result = 2) {; // tips = "Unknown error"; alert (tips);} else if (obj. result = 3) {; // tips = "parameter error"; alert (tips) ;}; // check whether the SD card callback function already exists (step: 3) uexFileMgr. cbIsFileExistByPath = function (opCode, dataType, data) {Log ('uexfilemgr. cbIsFileExistByPath flag_sdcard = '+ flag_sdcard +', data = '+ data); if (flag_sdcard = 0) {if (data = 0) {Log ('sdcard does not exist, handle ');} else {// execute the check to update uexWidget. checkUpdate (); // according to config. check the update address configured in xml to initiate an http request} flag_sdcard = 1 ;}}; // Obtain the callback function of the platform version. check whether the client is the client of that platform (step: 2) uexWidgetOne. cbGetPlatform = function (opId, Ype, data) {Log ('uexwidgetone. cbGetPlatform '); // callback function for obtaining system version information platform = data; Log ('Platform =' + platform); if (data = 0) {// iphone uexWidget. checkUpdate (); // directly call to check for updates and check that the update address is in config. the xml contains the configuration} else if (data = 1) {// android flag_sdcard = 0; uexFileMgr. isFileExistByPath ('/sdcard/'); // first judge whether an SD card exists, and then call checkUpdate for update} else {// platform}; uexWidgetOne. getPlatform (); // Obtain the platform version (step: 1)} function Log (s) {uexLog. sendLog (s);} function getVersionContent () {var url = web_url + "version. php "; uexXmlHttpMgr. onData = getvSuccess; uexXmlHttpMgr. open (777, "get", url, ""); uexXmlHttpMgr. send (777);} function getvSuccess (opid, status, result) {if (status =-1) {uexWindow. toast ("0", "5", "cannot connect to the network ^_^ oh", "3000");} if (status = 1) {uexXmlHttpMgr. close (777); uexWindow. closeToast (); if (result = "[]") {uexWindow. toast ("0", "5", "none", "2000");} else {var con = eval ('+ result + ')') var value = "later; update"; var mycars = value. split (";"); uexWindow. confirm (con. vtitle, con. vcontent, mycars); // A prompt box is displayed, whether to confirm the update }}}

Enter the configuration update address in the config. xml file of the app as follows:

Http://www.i2ty.com/update.php

APP update prompt:

The pop-up window content can be customized according to the version. php file content.

The above content explains how to use the Appcan client to automatically update the PHP version number.

Snapshot (full), appcan version number is automatically updated on the app during project development. check the relevant information and then update the Appcan client automatically...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.