Using PHP for mobile interface development tools (using the Thinkphp framework) None? Php *** Createdbyzhangkx * Email: zkx520tnhb@163.com * Date: 201581 * Time: 23: 15 ******* * ****************** @ paramnull $ msg returns
Using PHP for mobile interface development tools (using the Thinkphp framework) None? Php/*** Created by zhangkx * Email: zkx520tnhb@163.com * Date: 2015/8/1 * Time: * // ****************************** api development auxiliary function ***** * **************** // ***** @ param null $ msg returns
Using PHP for mobile interface development tools (using Think php Framework) <无>
'Success', 'msg '=> $ msg, 'data' => $ data); print json_encode ($ result );} /*** @ param null $ msg returns the Error message * @ param flag success CURD operation failed * Function descript: returns the flag 'error ', and the json array */function returnApiError ($ msg = null) {$ result = array ('flag' => 'error ', 'msg '=> $ msg,); print json_encode ($ result );} /*** @ param null $ msg returns the error message * @ param flag success CURD operation failed * Function descript: Return flag Information 'error', and prompt information. The current system is busy. Please try again later; */function returnApiErrorExample () {$ result = array ('flag' => 'error ', 'msg '=>' the current system is busy. Please try again later! ',); Print json_encode ($ result);}/*** @ param null $ data * @ return array | mixed | null * Function descript: filter parameters submitted by post; **/function checkDataPost ($ data = null) {if (! Empty ($ data) {$ data = explode (',', $ data); foreach ($ data as $ v) {if ((! Isset ($ _ POST [$ v]) | (empty ($ _ POST [$ v]) {if ($ _ POST [$ v]! = 0 & $ _ POST [$ v]! = '0') {returnApiError ($ v. 'value is blank! ') ;}} Unset ($ data); $ data = I ('Post. '); unset ($ data [' _ URL _ '], $ data ['Token']); return $ data ;}} /*** @ param null $ data * @ return array | mixed | null * Function descript: filter parameters submitted by get. **/function checkcyclet ($ data = null) {if (! Empty ($ data) {$ data = explode (',', $ data); foreach ($ data as $ v) {if ((! Isset ($ _ GET [$ v]) | (empty ($ _ GET [$ v]) {if ($ _ GET [$ v]! = 0 & $ _ GET [$ v]! = '0') {returnApiError ($ v. 'value is blank! ') ;}} Unset ($ data); $ data = I ('get. '); unset ($ data [' _ URL _ '], $ data ['Token']); return $ data ;}}
/***** Publish module ** obtain detailed information about a single fruit **/public function getMyReleaseInfo () {// check whether the data checkdataPost ('id') is obtained through the post method '); $ where ['id'] = $ _ POST ['id']; $ field [] = 'id, fruit_name, high_price, low_price, address, size, weight, fruit_pic, remark'; $ releaseInfo = $ this-> release_obj-> findRelease ($ where, $ field); $ releaseInfo ['remark'] = mb_substr ($ releaseInfo ['remark'], 0, 49, 'utf-8 '). '... '; // multiple graph addresses use commas to intercept strings. If an empty array exists after intercept, filter out $ r. EleaseInfo ['fruit _ pic '] = array_filter (explode (', ', $ releaseInfo ['fruit _ pic']); $ fruit_pic = $ releaseInfo ['fruit _ pic ']; unset ($ releaseInfo ['fruit _ pic']); // Add the storage path foreach ($ fruit_pic as $ k => $ v) {$ releaseInfo ['fruit _ pic '] [] = 'HTTP ://'. $ _ SERVER ['HTTP _ host']. '/Uploads/Release /'. $ v;} if ($ releaseInfo) {returnApiSuccess ('', $ releaseInfo);} else {returnApiError ('nothing found (+ _ + )! ');}}
/*** Query a piece of data */public function findRelease ($ where, $ field) {if ($ where ['status'] = ''| empty ($ where ['status']) {$ where ['status'] = array ('neq', '9');} $ result = $ this-> where ($ where)-> field ($ field) -> find (); return $ result ;}
{"Flag": "success", "message": "", "responseList": {"id": "2", "fruit_name": "apple ", "high_price": "8.0", "low_price": "5.0", "address": "Tianjin bailou fruit market", "size": "2.0", "weight ": "2.0", "remark": "urgently needed... "," fruit_pic ": [" http://fruit.txunda.com/Uploads/Release/201508/55599e7514815.png "," http://fruit.txunda.com/Uploads/Release/201508/554f2dc45b526.jpg "]}
{"flag":"success","message":"","responseList":{"id":"2","fruit_name":"\u82f9\u679c","high_price":"8.0","low_price":"5.0","address":"\u5929\u6d25\u5c0f\u767d\u697c\u6c34\u679c\u5e02\u573a","size":"2.0","weight":"2.0","remark":"\u6025\u9700...","fruit_pic":["http:\/\/fruit.txunda.com\/Uploads\/Release\/201508\/55599e7514815.png","http:\/\/fruit.txunda.com\/Uploads\/Release\/201508\/554f2dc45b526.jpg"]}}