Free two-dimensional code generation approach very much! For example, the more famous of the two-dimensional code fodder, if only simple to use, use it enough. But if you want a large-scale production, it would not be appropriate. Furthermore many tools logo in no way to join the two-dimensional code (the same as the micro-channel two-dimensional code).
Next, I would talk about how fast, high quality, highly customizable generate a two-dimensional code.
Two-dimensional code encoding algorithm is public, which means that most of the development language can generate dynamic map. But in the two-dimensional code so widely used today, but also to build their own wheels, if not stupid, and that is being a real technology geek.
There are open-source Java-dimensional code generation library: com.google.zxing, this is the big brother to Google android open source, this library is quite strong, but a pit of force, with who knows who it
python is notoriously third-party libraries and more, how it got less two-dimensional code generation. For example: myqr, qrcode such as
other languages are not familiar with, do not discuss ...
Now that I'm talking about any development language can generate two-dimensional code, implemented independently outside apart from each language. There is also a program that calls the existing API to generate two-dimensional code. For those who want a simple to use, to control development costs or minority languages to use some occasions, it is a good strategy to use the API.
Here I recommend a two-dimensional code free API generated from " green onion computing "
detailed documentation: https://www.xiaocongjisuan.com/show/api/14
API parameter passing notes:
- appKey: Interface uniquely identify the user in the background - I Interface View> -> Application Center
- openId: platform id, the system automatically generates a registration, the user background - Account Information View> -> Users
Why recommend this interface it? Since it generates only two-dimensional code is highly customizable, such as: logo, a color two-dimensional code, the background color of the two-dimensional code, the two-dimensional code size, margins and the like, is provided in detail as follows:
There are some instructions to return the value of the specific reference to the above api documentation it! Next, I posted about some use DEMO common development language.
java version:
package com.xiaocongjisuan.module.example; import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; public class Application { public static final String DEF_CHATSET = "UTF-8"; Public static Final int DEF_CONN_TIMEOUT = 30000 ; public static Final int DEF_READ_TIMEOUT = 30000 ; public static String userAgent = "Mozilla / 5.0 (Windows NT 6.1) AppleWebKit / 537.36 (KHTML, like Gecko) Chrome / 29.0.1547.66 Safari / 537.36" ; // configure your application appKey and openid public static Final String APP_KEY = "Yours" ; public static Final String OPEN_ID = "Yours" ; // will map-based to a request parameter type public static String urlEncode(Map<String,Object> params) { if(params==null){return "";}; StringBuilder sb = new StringBuilder(); for (Map.Entry<String,Object> i : params.entrySet()) { try { sb.append(i.getKey()).append("=").append(URLEncoder.encode(i.getValue()+"","UTF-8")).append("&"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } String r=sb.toString (); IF (r.endsWith ( "&" )) { R & lt = r.substring (0, r.length () -. 1 ); } return R & lt; } / ** * * @param requestUrl request address * @param the params request parameter * @param method request method * @return request result * @throws Exception * / public static String requestContent (String requestUrl, the Map <String, Object> the params, String method) throws Exception { the HttpURLConnection Conn= null; BufferedReader reader = null; String rs = null; try { //组装请求链接 StringBuffer sb = new StringBuffer(); if(method!=null&&method.equalsIgnoreCase("get")){ requestUrl = requestUrl+"?"+urlEncode(params); } //默认get URL url = new URL(requestUrl); conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); if(method!=null&&method.equalsIgnoreCase("post")){ conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.setDoInput(true); } //参数配置 conn.setRequestProperty("User-agent", userAgent); conn.setUseCaches(false); conn.setConnectTimeout(DEF_CONN_TIMEOUT); conn.setReadTimeout(DEF_READ_TIMEOUT); conn.setInstanceFollowRedirects(false); conn.connect(); if (params!= null && method.equalsIgnoreCase("post")) { try { DataOutputStream out = new DataOutputStream(conn.getOutputStream()); out.writeBytes(urlEncode(params)); } catch (Exception e) { e.printStackTrace(); } } //读取数据 InputStream is = conn.getInputStream(); reader = new BufferedReader(new InputStreamReader(is, DEF_CHATSET)); String strRead = null; while ((strRead = reader.readLine()) != null) { sb.append(strRead); } rs = sb.toString(); } catch (IOException e) { e.printStackTrace(); } finally { if (reader != null) { reader.close(); } if (conn != null) { conn.disconnect(); } } return rs; } public static void main(String[] args) throws Exception{ String domain="http://api.xiaocongjisuan.com/"; String servlet="develop/qrcode/create"; String method="get"; String requestUrl=domain+servlet; Map<String,Object> params=new HashMap<String,Object>(); params.put("appKey",APP_KEY); params.put("openId",OPEN_ID); //变动部分 params.put("text","我是最可爱的小伙子"); params.put("w",400); params.put("m",1); params.put("color","000000"); params.put("bgColor","ffffff"); String result=requestContent(requestUrl,params,method); System.out.println(result); } }
python version:
# - * - Coding: UTF-8 - * - # flake8: noqa __author__ = ' wukong ' Import urllib from urllib Import urlencode # Configure appKey and openId you are applying app_key = " *** " open_id = " *** " " "" request_url request address params request parameter method request method "" " DEF Request_Content (request_url, params, method): params = urlencode (params) IF method and method.lower () == "get": f = urllib.urlopen("%s?%s" % (request_url, params)) else: f = urllib.urlopen(request_url, params) content = f.read() print content def main(): domain="http://api.xiaocongjisuan.com/"; servlet="develop/qrcode/create" method="get" request_url=domain+servlet #字典 the params = {} the params [ " AppKey " ] = app_key the params [ " OpenID " ] = open_id # variable portion of the params [ " text " ] = " I is the sweetest guy " the params [ " W " ] = 400 the params [ " m " ] =. 1 the params [ " Color " ] = " 000000 " the params [ " bgColor " ] = "ffffff" request_content(request_url,params,method) if __name__ == '__main__': main()
php version:
<Meta HTTP-equiv = " Content-Type " Content = " text / HTML; charset = UTF-8 " /> < PHP? / ** * @author * @copyright 2019 * / header ( " Content-of the type: text / HTML; charset = UTF-. 8 " ); // set the encoding // configure your application appKey and OpenID $ app_key = " *** " ; $ open_id = " *** " ; / ** $ URL request address $ params request parameter $ isPost request method * / function http_curl (URL $, $ the params=false,$ispost=false){ $httpInfo = array(); $ch = curl_init(); curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 ); curl_setopt( $ch, CURLOPT_USERAGENT , "xiaocongjisuan"); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 ); curl_setopt( $ch, CURLOPT_TIMEOUT , 60); curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true ); if( $ispost ) { curl_setopt( $ch , CURLOPT_POST , true ); curl_setopt( $ch , CURLOPT_POSTFIELDS , $params ); curl_setopt( $ch , CURLOPT_URL , $url ); } else { if($params){ curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params ); }else{ curl_setopt( $ch , CURLOPT_URL , $url); } } $response = curl_exec( $ch ); if ($response === FALSE) { //echo "cURL Error: " . curl_error($ch); return false; } $httpCode = curl_getinfo( $ch , CURLINFO_HTTP_CODE ); $httpInfo = array_merge( $httpInfo , curl_getinfo( $ch ) ); curl_close( $ch ); return $response; } function main(){ global $app_key; global $open_id; $domain="http://api.xiaocongjisuan.com/"; $servlet="develop/qrcode/create"; $method="get"; $url=$domain."".$servlet; $params['appKey'] = $ App_key; $ params [ ' transcodingOpenID ' ] = $ open_id; // change portion $ the params [ " text " ] = " I is the sweetest guy " ; $ the params [ " W " ] = 400 ; $ the params [ " m " ] =. 1 ; $ the params [ " Color " ] = " 000000 " ; $ the params [ " bgColor " ] = " FFFFFF " ; // the foreach ($ AS the params Key $ =>$value) { $params[$key]=mb_convert_encoding($value, "UTF-8", "GBK"); } $paramstring = http_build_query($params); $content = http_curl($url,$paramstring,true); return $content; } echo main(); ?>
Other languages can view the detailed documentation. In fact, plainly, as long as the POST request transmission, two-dimensional code can be generated using the above method.
A method for generating the above-described two-dimensional bar code legend